...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
InputIterator
An input iterator is an iterator that can read through a sequence of values. It is single-pass (old values of the iterator cannot be re-used), and read-only.
An input iterator represents a position in a sequence. Therefore, the iterator can point into the sequence (returning a value when dereferenced and being incrementable), or be off-the-end (and not dereferenceable or incrementable).
value_type
std::iterator_traits<Iter>::value_type
The value type of the iterator (not necessarily what
*i
returns)
difference_type
std::iterator_traits<Iter>::difference_type
The difference type of the iterator
category
std::iterator_traits<Iter>::iterator_category
The category of the iterator
i
, j
x
category must be derived from std::input_iterator_tag, a model of DefaultConstructible, and a model of CopyConstructible.
value_type must be a model of CopyConstructible.
difference_type must be a model of SignedInteger.
Name | Expression | Type | Precondition | Semantics | Postcondition |
---|---|---|---|---|---|
Dereference |
*i |
Convertible to value_type |
|
||
Preincrement |
++i |
Iter & |
|
||
Postincrement |
i++ |
|
Equivalent to |
|
|
Postincrement and dereference |
*i++ |
Convertible to value_type |
|
Equivalent to |
|