C++ concepts: BidirectionalIterator - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# C++ concepts: BidirectionalIterator

From cppreference.com
< cpp‎ | concept

A `BidirectionalIterator` is a `ForwardIterator` that can be moved in both directions (i.e. incremented and decremented).

### [edit] Requirements

The type `It` satisfies `BidirectionalIterator` if

- The type `It` satisfies `ForwardIterator`

And, given

- `a` and `b`, iterators of type `It`
- `reference,` the type denoted by `std::iterator_traits<It>::reference`

The following expressions must be valid and have their specified effects

Expression | Return | Equivalent expression | Notes
--- | --- | --- | ---
--a | It& |  | Preconditions: `a` is decrementable (there exists such `b` that a == ++b) Postconditions: a is dereferenceable --(++a) == a If --a == --b then a == b &a == &--a
a-- | convertible to const It& | It temp = a; --a; return temp; |
*a-- | `reference` |  |

A `mutable BidirectionalIterator` is a `BidirectionalIterator` that additionally satisfies the `OutputIterator` requirements.

### [edit] Notes

The begin iterator is not decrementable and the behavior is undefined if --container.begin() is evaluated.

A bidirectional iterator does not have to be dereferenceable to be decrementable (in particular, the end iterator is not dereferenceable but is decrementable)

### [edit] See also

- Iterator library

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/concept/BidirectionalIterator&oldid=79180"