Question

Exacly as in the subject I use VS2010:

I have:

std::string s = std::to_string(42);

and the error

Error   4   error C2668: 'std::to_string' : ambiguous call to overloaded function

how to repair it?

Was it helpful?

Solution

Visual C++ 2010 has only three overloads for std::to_string that take long long, unsigned long long, and long double. The standard defines more than that, but VC++ 2010 doesn't support them. No conversion from the int literal 42 is preferred, so the call is ambiguous. Instead, you can use a different type of integer literal. For example:

std::string s = std::to_string(42LL);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top