This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofCD1 status.
Section: 27.4.3[basic.string]Status:CD1Submitter: Alisdair MeredithOpened: 2005-11-16Last modified: 2016-01-28
Priority:Not Prioritized
View otheractive issues in [basic.string].
View all otherissues in [basic.string].
View all issues withCD1 status.
Discussion:
OK, we all know std::basic_string is bloated and already has way toomany members. However, I propose it is missing 3 useful members thatare often expected by users believing it is a close approximation of thecontainer 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 itwas missing as we are switching to a more conforming standard library<g>
I find it particularly inconsistent to support push_back, but notpop_back.
ii/ back.
There are certainly cases where I want to examine the last character ofa string before deciding to append, or to trim trailing path separatorsfrom 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 recentlyadded to vector, or at() member added to the maps.
Proposed resolution:
Add the following members to definition of class template basic_string, 21.3p7
void pop_back ()const charT & front() constcharT & front()const charT & back() constcharT & back()
Add the following paragraphs to basic_string description
21.3.4p5
const charT & front() constcharT & front()Precondition:
!empty()Effects: Equivalent to
operator[](0).
21.3.4p6
const charT & back() constcharT & 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]
[Berlin: Has support. Alisdair provided wording.]