1039. Sequence container back function should also support const_iterator

Section: 26.2.3 [sequence.reqmts] Status: C++11 Submitter: Alisdair Meredith Opened: 2009-03-12 Last modified: 2016-02-10

Priority: Not Prioritized

View other active issues in [sequence.reqmts].

View all other issues in [sequence.reqmts].

View all issues with C++11 status.

Discussion:

Addresses UK 234 [CD1]

The reference to iterator in semantics for back should also allow for const_iterator when called on a const-qualified container. This would be ugly to specify in the 03 standard, but is quite easy with the addition of auto in this new standard.

[ Summit: ]

Agree.

[ Batavia (2009-05): ]

We agree with the proposed resolution. Move to Tentatively Ready.

Proposed resolution:

In 26.2.3 [sequence.reqmts] Table 84, replace iterator with auto in semantics for back:

Table 84 — Optional sequence container operations
Expression Return type Operational semantics Container
a.back() reference; const_reference for constant a { iterator auto tmp = a.end();
--tmp;
return *tmp; }
vector, list, deque, basic_string