This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.

1192. basic_string missing definitions for cbegin / cend / crbegin / crend

Section: 23.4.3.4 [string.iterators] Status: C++11 Submitter: Jonathan Wakely Opened: 2009-08-14 Last modified: 2016-01-28

Priority: Not Prioritized

View all issues with C++11 status.

Discussion:

Unlike the containers in clause 23, basic_string has definitions for begin() and end(), but these have not been updated to include cbegin, cend, crbegin and crend.

[ 2009-10-28 Howard: ]

Moved to Tentatively NAD after 5 positive votes on c++std-lib. Added rationale.

[ 2009-10-28 Alisdair disagrees: ]

I'm going to have to speak up as the dissenting voice.

I agree the issue could be handled editorially, and that would be my preference if Pete feels this is appropriate. Failing that, I really think this issue should be accepted and moved to ready. The other begin/end functions all have a semantic definition for this template, and it is confusing if a small few are missing.

I agree that an alternative would be to strike all the definitions for begin/end/rbegin/rend and defer completely to the requirements tables in clause 23. I think that might be confusing without a forward reference though, as those tables are defined in a later clause than the basic_string template itself. If someone wants to pursue this I would support it, but recommend it as a separate issue.

So my preference is strongly to move Ready over NAD, and a stronger preference for NAD Editorial if Pete is happy to make these changes.

[ 2009-10-29 Howard: ]

Moved to Tentatively Ready after 5 positive votes on c++std-lib. Removed rationale to mark it NAD. :-)

Proposed resolution:

Add to 23.4.3.4 [string.iterators]

iterator       begin();
const_iterator begin() const;
const_iterator cbegin() const;

...

iterator       end();
const_iterator end() const;
const_iterator cend() const;

...

reverse_iterator       rbegin();
const_reverse_iterator rbegin() const;
const_reverse_iterator crbegin() const;

...

reverse_iterator       rend();
const_reverse_iterator rend() const;
const_reverse_iterator crend() const;