Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
Front Page / Iterators / Concepts / Bidirectional Iterator

Bidirectional Iterator

Description

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

Refinement of

Forward Iterator

Definitions

Expression requirements

In addition to the requirements defined in Forward Iterator, the following requirements must be met.

Expression Type Complexity
next<i>::type Bidirectional Iterator Amortized constant time
prior<i>::type Bidirectional Iterator Amortized constant time
i::category Integral Constant, convertible to bidirectional_iterator_tag Constant time

Expression semantics

typedef prior<i>::type j;
Precondition:i is decrementable
Semantics:j is an iterator pointing to the previous element of the sequence
Postcondition:j is dereferenceable and incrementable

Invariants

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

See also

Iterators, Forward Iterator, Random Access Iterator, Bidirectional Sequence, prior