Home Dashboard Directory Help

Ambiguous use of the overloaded function std::string to_string(int val); by Сыроежка


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 742642
Opened: 5/18/2012 4:21:56 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
User(s) can reproduce this bug


The function std::string to_string(int val); does not declared for the fundamental type int. So the compiler issues errors that the use of the function is ambiguous. Header <string> contains the following declarations

inline string to_string(_Longlong _Val);
inline string to_string(_ULonglong _Val);
inline string to_string(long double _Val);

where _Longlong and _ULonglong are defined as

#define _LONGLONG    __int64
#define _ULONGLONG    unsigned __int64

So then there is a call

int x = 42;

std::string s = to_string( x );

the compiler issues errors.

Sign in to post a comment.
Posted by Microsoft on 5/29/2012 at 7:54 PM

Thanks for reporting this bug. We've already fixed it, and the fix will be available in VC11 RTM.

You may be interested to learn that this bug was caused by VC10 following an earlier version of the C++0x Working Paper, which specified too few overloads for to_string(). This was fixed in the final version of the C++11 Standard, and we've changed VC11's implementation accordingly.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by MS-Moderator08 [Feedback Moderator] on 5/20/2012 at 7:53 PM
Thank you for submitting feedback on Visual Studio 11 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 5/18/2012 at 4:44 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.