771. Impossible throws clause in [string.conversions]

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

Priority: Not Prioritized

View all other issues in [string.conversions].

View all issues with CD1 status.


The new to_string and to_wstring functions described in 24.3.4 [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 24.3 [string.classes] is correct in this regard).

Proposed resolution:

In 24.3.4 [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