Why is this call to overloaded function ambiguous?

I am a beginner in template programming and I am using the following template function trying to avoid code duplication:

template <class T>
void foo(T iInteger) {

    // ... same algorithm for all integer types

    std::to_string( static_cast<T>(iInteger) ); // C2668: ambiguous call to overloaded function

    // ... end of algorithm

}

My foo function will be called only with primitive integral types. I was naively thinking that static_cast would have been enough to tell the compiler which overload of std::to_string() to use, but this seems not enough as im still getting a C2668: ambiguous call to overloaded function. What am I missing? Is it possible to avoid duplicating the same code for all primitive integer types while still calling the appropriate std::to_string overload?

Answers


As pointed out by chris in the comments to the question, the problem is that I'm using VS2010, which does not fully implement the c++11 standard. std::to_string implements only overloads for long long, unsigned long long, long double. See this related question for more details on the matter.


Need Your Help

Mobile Safari (iPhone) CSS verticle centering/line-height CSS issues

iphone css mobile mobile-safari

Got an issue I've been trying to solve without much like for a while across various projects.

Index out of range for rectangle array?

c# arrays xna collision-detection rectangles

I have this problem with assigning individual rectangles to each value in an list. To try this out I first tried to give a rectangle to value 5.

hovering on text does not show the description properly

css sharepoint

Hi everyone, In sharepoint I am showing the list of titles and on hover it should show me the description. But somehow with my css i cannot see the description properly. Please find the image o...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.