Node:Bidirectional iterators, Next:Random access iterators, Previous:Forward iterators, Up:Iterators
--
|
Operator on bidirectional iterators |
A class or a built-in type X satisfies the requirements of a
bidirectional iterator if to the table that specifies forward iterators
we add the following lines:
|
| expression | return type | operational semantics | assertion/note 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.
| |
r-- | X |
{ X tmp = r;
--r;
return tmp; }
|
NOTE: Bidirectional iterators allow algorithms to move iterators backward as well as forward.