This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.
to_string / to_wstringSection: 27.4.5 [string.conversions] Status: C++11 Submitter: Christopher Jefferson Opened: 2009-11-10 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [string.conversions].
View all issues with C++11 status.
Discussion:
Reported on the gcc mailing list.
The code "
int i; to_string(i);" fails to compile, as 'int' is ambiguous between 'long long' and 'long long unsigned'. It seems unreasonable to expect users to cast numbers up to a larger type just to useto_string.
[ 2009-11-14 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]
Proposed resolution:
27.4 [string.classes], change to_string and
to_wstring to:
string to_string(int val); string to_string(unsigned val); string to_string(long val); string to_string(unsigned long val); string to_string(long long val); string to_string(unsigned long long val); string to_string(float val); string to_string(double val); string to_string(long double val); wstring to_wstring(int val); wstring to_wstring(unsigned val); wstring to_wstring(long val); wstring to_wstring(unsigned long val); wstring to_wstring(long long val); wstring to_wstring(unsigned long long val); wstring to_wstring(float val); wstring to_wstring(double val); wstring to_wstring(long double val);
In 27.4.5 [string.conversions], paragraph 7, change to:
string to_string(int val); string to_string(unsigned val); string to_string(long val); string to_string(unsigned long val); string to_string(long long val); string to_string(unsigned long long val); string to_string(float val); string to_string(double val); string to_string(long double val);7 Returns: each function returns a
stringobject holding the character representation of the value of its argument that would be generated by callingsprintf(buf, fmt, val)with a format specifier of"%d","%u","%ld","%lu","%lld","%llu","%f","%f", or"%Lf", respectively, wherebufdesignates an internal character buffer of sufficient size.
In 27.4.5 [string.conversions], paragraph 14, change to:
wstring to_wstring(int val); wstring to_wstring(unsigned val); wstring to_wstring(long val); wstring to_wstring(unsigned long val); wstring to_wstring(long long val); wstring to_wstring(unsigned long long val); wstring to_wstring(float val); wstring to_wstring(double val); wstring to_wstring(long double val);14 Returns: Each function returns a
wstringobject holding the character representation of the value of its argument that would be generated by callingswprintf(buf, buffsz, fmt, val)with a format specifier ofL"%d",L"%u",L"%ld",L"%lu",L"%lld",L"%llu",L"%f",L"%f", orL"%Lf", respectively, wherebufdesignates an internal character buffer of sufficient sizebuffsz.