Title
Iterator equality between different containers
Status
nad editorial
Section
[iterator.requirements][container.requirements]
Submitter
Andy Koenig

Created on 2003-12-16.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Insert a new paragraph between [iterator.requirements]/7+8:

[..] The result of the application of functions in the library to invalid ranges is undefined.

The result of directly or indirectly evaluating any comparison function or the binary - operator with two iterator values as arguments that were obtained from two different ranges r1 and r2 (including their past-the-end values) which are not subranges of one common range is undefined, unless explicitly described otherwise.

Date: 2010-10-21.18:28:33

Rationale:

Solved by N3066.

Date: 2010-10-21.18:28:33

[ 2010 Pittsburgh: Moved to NAD Editorial. Rationale added below. ]

Date: 2010-10-21.18:28:33

[ 2009-10 Santa Cruz: ]

Leave as Open. Alisdair has volunteered to refine the wording.

Date: 2009-09-20.00:00:00

[ 2009-09-20 Daniel provided wording. ]

Date: 2010-10-21.18:28:33

[ 2009-07 Frankfurt ]

Daniel volunteered to work on this.

Date: 2010-10-21.18:28:33

[ Sydney: The intention is that comparing two iterators from different containers is undefined, but it's not clear if we say that, or even whether it's something we should be saying in clause 23 or in clause 24. Intuitively we might want to say that equality is defined only if one iterator is reachable from another, but figuring out how to say it in any sensible way is a bit tricky: reachability is defined in terms of equality, so we can't also define equality in terms of reachability. ]

Date: 2003-12-16.00:00:00

What requirements does the standard place on equality comparisons between iterators that refer to elements of different containers. For example, if v1 and v2 are empty vectors, is v1.end() == v2.end() allowed to yield true? Is it allowed to throw an exception?

The standard appears to be silent on both questions.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2666
2010-10-21 18:28:33adminsetmessages: + msg2665
2010-10-21 18:28:33adminsetmessages: + msg2664
2010-10-21 18:28:33adminsetmessages: + msg2663
2010-10-21 18:28:33adminsetmessages: + msg2662
2010-10-21 18:28:33adminsetmessages: + msg2661
2010-10-21 18:28:33adminsetmessages: + msg2660
2003-12-16 00:00:00admincreate