Title
Bidirectional iterator assertion typo
Status
cd1
Section
[bidirectional.iterators]
Submitter
ysapir (submitted via comp.std.c++)

Created on 2002-10-17.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

Fixes an obvious typo

Date: 2010-10-21.18:28:33

Proposed resolution:

Change the guarantee to "postcondition: r is dereferenceable."

Date: 2012-11-04.20:01:26

Following a discussion on the boost list regarding end iterators and the possibility of performing operator--() on them, it seems to me that there is a typo in the standard. This typo has nothing to do with that discussion.

I have checked this newsgroup, as well as attempted a search of the Active/Defect/Closed Issues List on the site for the words "s is derefer" so I believe this has not been proposed before. Furthermore, the "Lists by Index" mentions only DR 299 on section 24.1.4, and DR 299 is not related to this issue.

The standard makes the following assertion on bidirectional iterators, in section 24.1.4 [lib.bidirectional.iterators], Table 75:

                         operational  assertion/note
expression  return type   semantics    pre/post-condition

--r          X&                        pre: there exists s such
                                       that r == ++s.
                                       post: s is dereferenceable.
                                       --(++r) == r.
                                       --r == --s implies r == s.
                                       &r == &--r.

(See http://lists.boost.org/Archives/boost/2002/10/37636.php.)

In particular, "s is dereferenceable" seems to be in error. It seems that the intention was to say "r is dereferenceable".

If it were to say "r is dereferenceable" it would make perfect sense. Since s must be dereferenceable prior to operator++, then the natural result of operator-- (to undo operator++) would be to make r dereferenceable. Furthermore, without other assertions, and basing only on precondition and postconditions, we could not otherwise know this. So it is also interesting information.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2424
2010-10-21 18:28:33adminsetmessages: + msg2423
2002-10-17 00:00:00admincreate