In attempting to insert integer values into a string, I thought that my prayers were answered when I found std::to_string, but for some reason whenever I actually try to use it, Visual Studio complains about ambiguity. Here is the current incarnation of my function:
string get_time_remaining (int elapsed) { string remaining; string temp_string; int time_remaining = TimeLimit - elapsed; int temp_int; temp_int = int(time_remaining / 3600); if(temp_int == 0) remaining = "00 : "; else { temp_string = std::to_string(temp_int); // Here! remaining = temp_string + " : "; } temp_int = time_remaining % 60 + 1; if(temp_int < 10) remaining = remaining + "0"; temp_string = std::to_string(temp_int); remaining = remaining + temp_string; return remaining; } I have tried casting temp_int inside the call to to_string, and as you can see I even tried casting the result of what should be integer division, but no matter what I do, VS spits this out at me:
d:\my programs\powerplay\powerplay\powerplay.cpp(1285): error C2668: 'std::to_string' : ambiguous call to overloaded function 1> d:\microsoft visual studio 10.0\vc\include\string(688): could be 'std::string std::to_string(long double)' 1> d:\microsoft visual studio 10.0\vc\include\string(680): or 'std::string std::to_string(_ULonglong)' 1> d:\microsoft visual studio 10.0\vc\include\string(672): or 'std::string std::to_string(_Longlong)' Any help would be appreciated.