This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

771. Impossible throws clause in [string.conversions]

Section: 23.4.5 [string.conversions] Status: CD1 Submitter: Daniel Krügler Opened: 2008-01-13 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [string.conversions].

View all issues with CD1 status.

Discussion:

The new to_string and to_wstring functions described in 23.4.5 [string.conversions] have throws clauses (paragraphs 8 and 16) which say:

Throws: nothing

Since all overloads return either a std::string or a std::wstring by value this throws clause is impossible to realize in general, since the basic_string constructors can fail due to out-of-memory conditions. Either these throws clauses should be removed or should be more detailled like:

Throws: Nothing if the string construction throws nothing

Further there is an editorial issue in p. 14: All three to_wstring overloads return a string, which should be wstring instead (The header <string> synopsis of 23.4 [string.classes] is correct in this regard).

Proposed resolution:

In 23.4.5 [string.conversions], remove the paragraphs 8 and 16.

string to_string(long long val); 
string to_string(unsigned long long val); 
string to_string(long double val); 

Throws: nothing

wstring to_wstring(long long val); 
wstring to_wstring(unsigned long long val); 
wstring to_wstring(long double val); 

Throws: nothing