Title
basic_string::operator[] and const correctness
Status
cd1
Section
[string.capacity]
Submitter
Chris Newton

Created on 2000-08-27.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

In section 21.3.4, paragraph 1, change "data()[pos]" to "*(begin() + pos)".

Date: 2000-08-27.00:00:00

Paraphrased from a message that Chris Newton posted to comp.std.c++:

The standard's description of basic_string<>::operator[] seems to violate const correctness.

The standard (21.3.4/1) says that "If pos < size(), returns data()[pos]." The types don't work. The return value of data() is const charT*, but operator[] has a non-const version whose return type is reference.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2035
2000-08-27 00:00:00admincreate