boost::mpl::Bidirectional Iterator

# Bidirectional Iterator

### Description

A Bidirectional Iterator is a Forward Iterator that provides a way to obtain the previous element in a sequence.

### Refinement of

Forward Iterator

### Definitions

- a bidirectional iterator `i` is decrementable if there is a "previous" iterator, that is, if `i::prior` expression is well-defined; iterators pointing to the first element of the sequence are not decrementable.

### Valid expressions

Bidirectional Iterator both defines a new expression and refines the one described in Forward Iterator.

Expression | Expression type
--- | ---
`typename i::next` | A model of Bidirectional Iterator
`typename i::prior` | A model of Bidirectional Iterator

### Expression semantics

Semantics of an expression is defined only where it is not defined in Forward Iterator.

Expression | Complexity | Precondition | Semantics | Postcondition
--- | --- | --- | --- | ---
`typename i::prior` | Amortized constant time | `i` is decrementable | `i::prior` is an iterator pointing to the previous element of the sequence | `i::prior` is dereferencable and incrementable

### Invariants

For any bidirectional iterators `i` and `j` the following invariants always hold:

- if `i` is incrementable, then `i::next::prior` is a null operation; similarly, if `i` is decrementable, `i::prior::next` is a null operation.

### See also

Bidirectional Sequence, Forward Iterator, Random Access Iterator

Table of Contents
Last edited July 15, 2002 11:33 am