This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++11 status.
RandomAccessIterator'soperator- has nonsensical effects clauseSection: 24.3.5.7[random.access.iterators]Status:C++11Submitter: Doug GregorOpened: 2009-03-20Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [random.access.iterators].
View all issues withC++11 status.
Discussion:
Addresses UK 265
UK-265:
This effects clause is nonesense. It looks more like an axiom statingequivalence, and certainly an effects clause cannot change the state oftwo 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 LWG1079(i), the wording in the issue no longer exists, andappears to be entirely an artefact of the concepts wording.
This issue is currently on our Ready list (not even Tentative!) but I think ithas 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 theremoval of concepts". Unfortunately it is too late to poll again, so we willhave 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
-8-nofdifference_typesuch thata == b + n.Effects:-9-Returns:b == a + (b - a)(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 tobidirectional iterator) Expression Return type Operational semantics Assertion/note
pre-/post-conditionb - aDistancereturndistance(a,b)npre: there exists a value nofDistancesuch thata +n == b.b == a + (b - a).