Title
Impossible throws clause in [string.conversions]
Status
cd1
Section
[string.conversions]
Submitter
Daniel Krügler

Created on 2008-01-13.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

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

Date: 2008-01-13.00:00:00

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

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3717
2008-01-13 00:00:00admincreate