Title
Clarify possible sameness of associative container's iterator and const_iterator
Status
c++11
Section
[associative.reqmts]
Submitter
Alisdair Meredith

Created on 2009-03-12.00:00:00 last changed 161 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

In [associative.reqmts] p6, add:

-6- iterator of an associative container meets the requirements of the BidirectionalIterator concept. For associative containers where the value type is the same as the key type, both iterator and const_iterator are constant iterators. It is unspecified whether or not iterator and const_iterator are the same type. [Note: iterator and const_iterator have identical semantics in this case, and iterator is convertible to const_iterator. Users can avoid violating the One Definition Rule by always using const_iterator in their function parameter lists -- end note]

Date: 2010-10-21.18:28:33

[ Batavia (2009-05): ]

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

Date: 2010-10-21.18:28:33

[ Summit: ]

Agree with issue. Agree with adding the note but not with changing the normative text. We believe the note provides sufficient guidance.

Date: 2012-10-21.13:19:07

Addresses UK 238 [CD1]

Leaving it unspecified whether or not iterator and const_iterator are the same type is dangerous, as user code may or may not violate the One Definition Rule by providing overloads for both types. It is probably too late to specify a single behaviour, but implementors should document what to expect. Observing that problems can be avoided by users restricting themselves to using const_iterator, add a note to that effect.

Suggest Change 'unspecified' to 'implementation defined'.

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-10-21 18:28:33adminsetmessages: + msg442
2010-10-21 18:28:33adminsetmessages: + msg441
2010-10-21 18:28:33adminsetmessages: + msg440
2009-03-12 00:00:00admincreate