...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
A Forward Iterator traverses a Sequence allowing movement in only one direction through it's elements, one element at a time.
Notation
Forward Iterators
Forward Iterator types
An MPL integral constant
An integral constant
A type models Forward Iterator if, in addition to being CopyConstructable, the following expressions are valid:
Expression |
Return type |
Runtime Complexity |
---|---|---|
next(i) |
Constant |
|
i == j |
Convertible to bool |
Constant |
i != j |
Convertible to bool |
Constant |
advance_c<N>(i) |
Constant |
|
advance<M>(i) |
Constant |
|
distance(i, j) |
result_of::distance<I, J>::type |
Constant |
deref(i) |
result_of::deref<I>::type |
Constant |
*i |
result_of::deref<I>::type |
Constant |
Expression |
Compile Time Complexity |
---|---|
result_of::next<I>::type |
Amortized constant time |
result_of::equal_to<I, J>::type |
Amortized constant time |
result_of::advance_c<I, N>::type |
Linear |
result_of::advance<I ,M>::type |
Linear |
result_of::distance<I ,J>::type |
Linear |
result_of::deref<I>::type |
Amortized constant time |
result_of::value_of<I>::type |
Amortized constant time |
Expression |
Semantics |
---|---|
next(i) |
An iterator to the element following i |
i == j |
Iterator equality comparison |
i != j |
Iterator inequality comparison |
advance_c<N>(i) |
An iterator n elements after i in the sequence |
advance<M>(i) |
Equivalent to advance_c<M::value>(i) |
distance(i, j) |
The number of elements between i and j |
deref(i) |
The element at positioni |
*i |
Equivalent to deref(i) |
The following invariants always hold: