Node:Bidirectional iterators, Next:, Previous:Forward iterators, Up:Iterators



Bidirectional 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:

Table 5: Bidirectional iterator requirements (in addition to forward iterator)

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.