CONCEPT BIDIRE(7)

NAME
BidirectionalIterator

DESCRIPTION

A bidirectional iterator is an iterator that can read through a sequence of values. It can move in either direction through the sequence, and can be either mutable (data pointed to by it can be changed) or not mutable.

An iterator represents a position in a sequence. Therefore, the iterator can point into the sequence (returning a value when dereferenced and being incrementable), or be off-the-end (and not dereferenceable or incrementable).

REFINEMENT OF

    &#8226; ForwardIterator

ASSOCIATED TYPES

    &#8226; value_type

    std::iterator_traits<Iter>::value_type
    The value type of the iterator

    &#8226; category

    std::iterator_traits<Iter>::iterator_category
    The category of the iterator

NOTATION

Iter
    A type playing the role of iterator-type in the BidirectionalIterator concept.

i, j
    Objects of type Iter

x
    Object of type value_type

TYPE EXPRESSIONS

Category tag
    category must be derived from std::bidirectional_iterator_tag.

VALID EXPRESSIONS
Name | Expression | Type | Precondition | Semantics | Postcondition
Predecrement | --i | Iter & | i is incrementable (not off-the-end) and some dereferenceable iterator j exists such that i == ++j |  |
Postdecrement | i-- | Iter | Same as for predecrement | Equivalent to {Iter j = i; --i; return j;} | i is dereferenceable or off-the-end

COMPLEXITY

All iterator operations must take amortized constant time.

INVARIANTS

Predecrement must return object
    &i = &(--i)

Unique path through sequence
    i == j implies --i == --j

Increment and decrement are inverses
    ++i; --i; and --i; ++i; must end up with the value of i unmodified, if i both of the operations in the pair are valid.

MODELS

    &#8226; T *

    &#8226; std::list<T>::iterator

SEE ALSO

    &#8226; RandomAccessIterator