Section: 27.4.3 [basic.string] Status: TC1 Submitter: Nico Josuttis Opened: 1998-09-29 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [basic.string].
View all other issues in [basic.string].
View all issues with TC1 status.
Duplicate of: 89
Discussion:
Many string member functions throw if size is getting or exceeding npos. However, I wonder why they don't throw if size is getting or exceeding max_size() instead of npos. May be npos is known at compile time, while max_size() is known at runtime. However, what happens if size exceeds max_size() but not npos, then? It seems the standard lacks some clarifications here.
Proposed resolution:
After 27.4.3 [basic.string] paragraph 4 ("The functions described in this clause...") add a new paragraph:
For any string operation, if as a result of the operation,
size()
would exceedmax_size()
then the operation throwslength_error
.
Rationale:
The LWG believes length_error is the correct exception to throw.