Section: 24.3.2 [basic.string] Status: CD1 Submitter: Alisdair Meredith Opened: 2005-11-16 Last modified: 2016-02-10
Priority: Not Prioritized
View other active issues in [basic.string].
View all other issues in [basic.string].
View all issues with CD1 status.
OK, we all know std::basic_string is bloated and already has way too many members. However, I propose it is missing 3 useful members that are often expected by users believing it is a close approximation of the container concept. All 3 are listed in table 71 as 'optional'
This is the one I feel most strongly about, as I only just discovered it was missing as we are switching to a more conforming standard library <g>
I find it particularly inconsistent to support push_back, but not pop_back.
There are certainly cases where I want to examine the last character of a string before deciding to append, or to trim trailing path separators from directory names etc. *rbegin() somehow feels inelegant.
This one I don't feel strongly about, but if I can get the first two, this one feels that it should be added as a 'me too' for consistency.
I believe this would be similarly useful to the data() member recently added to vector, or at() member added to the maps.
Add the following members to definition of class template basic_string, 21.3p7
void pop_back () const charT & front() const charT & front() const charT & back() const charT & back()
Add the following paragraphs to basic_string description
const charT & front() const charT & front()
Effects: Equivalent to operator(0).
const charT & back() const charT & back()
Effects: Equivalent to operator( size() - 1).
void pop_back ()
Effects: Equivalent to erase( size() - 1, 1 ).
Update Table 71: (optional sequence operations) Add basic_string to the list of containers for the following operations.
a.front() a.back() a.push_back() a.pop_back() a[n]
[ Berlin: Has support. Alisdair provided wording. ]