Dear friends:
I am trying to convert a double to string format using the std::to_string function, but it gives me the following error message. i do not understand why the functgion does not support the double format. i use the vs2010.

> error C2668: 'std::to_string' : ambiguous call to overloaded function
1>          E:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(688): could be 'std::string std::to_string(long double)'
1>          E:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(680): or       'std::string std::to_string(_ULonglong)'
1>          E:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(672): or       'std::string std::to_string(_Longlong)'
1>          while trying to match the argument list '(double)'

Can you post the code that is causing this order?

It's a bug in the compiler you're using. It has incomplete to_string support. There should be an update available from Microsoft.

Till than, you can make use of what C++ already offers you:

std::string to_string(double nr){
    std::stringstream token;
    token<<nr;
    return token.str();
}

Have you tried declaring your double as long double? Fixed the problem for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.