1079. UK-265: RandomAccessIterator's operator- has nonsensical effects clause

Section: 24.3.5.7 [random.access.iterators] Status: C++11 Submitter: Doug Gregor Opened: 2009-03-20 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [random.access.iterators].

View all issues with C++11 status.

Discussion:

Addresses UK 265

UK-265:

This effects clause is nonesense. It looks more like an axiom stating equivalence, and certainly an effects clause cannot change the state of two arguments passed by const reference

[ 2009-09-18 Alisdair adds: ]

For random access iterators, the definitions of (b-a) and (a<b) are circular:

From table Table 104 -- Random access iterator requirements:

b - a :==>  (a < b) ? distance(a,b) : -distance(b,a)

a < b :==>  b - a > 0

[ 2009-10 Santa Cruz: ]

Moved to Ready.

[ 2010-02-13 Alisdair opens. ]

Looking again at LWG 1079, the wording in the issue no longer exists, and appears to be entirely an artefact of the concepts wording.

This issue is currently on our Ready list (not even Tentative!) but I think it has to be pulled as there is no way to apply the resolution.

Looking at the current paper, I think this issue is now "NAD, solved by the removal of concepts". Unfortunately it is too late to poll again, so we will have to perform that review in Pittsburgh.

[ 2010-02-13 Daniel updates the wording to address the circularity problem. ]

[ The previous wording is preserved here: ]

Modify 24.3.5.7 [random.access.iterators]p7-9 as follows:

difference_type operator-(const X& a, const X& b);

-7- Precondition: there exists a value n of difference_type such that a == b + n.

-8- Effects: b == a + (b - a)

-9- Returns: (a < b) ? distance(a,b) : -distance(b,a)n

[ 2010 Pittsburgh: ]

Moved to Ready for Pittsburgh.

Proposed resolution:

Modify Table 105 in 24.3.5.7 [random.access.iterators]:

Table 105 — Random access iterator requirements (in addition to bidirectional iterator)
Expression Return type Operational semantics Assertion/note
pre-/post-condition
b - a Distance distance(a,b) return n pre: there exists a value n of Distance such that a + n == b. b == a + (b - a).