Bidirectional Range

| Home | Libraries | People | FAQ | More

### Bidirectional Range

##### Notation

`X` | A type that is a model of Bidirectional Range.
`a` | Object of type X.

##### Description

This concept provides access to iterators that traverse in both directions (forward and reverse). The `boost::range_iterator<X>::type` iterator must meet all of the requirements of Bidirectional Traversal Iterator.

##### Refinement of

Forward Range

##### Associated types

Reverse Iterator type | `boost::range_reverse_iterator<X>::type` | The type of iterator used to iterate through a Range's elements in reverse order. The iterator's value type is expected to be the Range's value type. A conversion from the reverse iterator type to the const reverse iterator type must exist.
Const reverse iterator type | `boost::range_reverse_iterator<const X>::type` | A type of reverse iterator that may be used to examine, but not to modify, a Range's elements.

##### Valid expressions

Name | Expression | Return type | Semantics
--- | --- | --- | ---
Beginning of range | `boost::rbegin(a)` | `boost::range_reverse_iterator<X>::type` if `a` is mutable `boost::range_reverse_iterator<const X>::type` otherwise. | Equivalent to `boost::range_reverse_iterator<X>::type(boost::end(a))`.
End of range | `boost::rend(a)` | `boost::range_reverse_iterator<X>::type` if `a` is mutable, `boost::range_reverse_iterator<const X>::type` otherwise. | Equivalent to `boost::range_reverse_iterator<X>::type(boost::begin(a))`.

##### Complexity guarantees

`boost::rbegin(a)` has the same complexity as `boost::end(a)` and `boost::rend(a)` has the same complexity as `boost::begin(a)` from Forward Range.

##### Invariants

Valid reverse range | For any Bidirectional Range a, `[boost::rbegin(a),boost::rend(a))` is a valid range, that is, `boost::rend(a)` is reachable from `boost::rbegin(a)` in a finite number of increments.
Completeness | An algorithm that iterates through the range `[boost::rbegin(a),boost::rend(a))` will pass through every element of `a`.

##### See also

Implementation of metafunctions

Implementation of functions