Created on 2005-11-16.00:00:00 last changed 172 months ago
[ Berlin: Has support. Alisdair provided wording. ]
Proposed resolution:
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
21.3.4p5
const charT & front() const charT & front()Precondition: !empty()
Effects: Equivalent to operator[](0).
21.3.4p6
const charT & back() const charT & back()Precondition: !empty()
Effects: Equivalent to operator[]( size() - 1).
21.3.5.5p10
void pop_back ()Precondition: !empty()
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]
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'
i/ pop_back.
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.
ii/ 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.
iii/ front
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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg2980 |
2010-10-21 18:28:33 | admin | set | messages: + msg2979 |
2005-11-16 00:00:00 | admin | create |