...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
OutputIterator
An output iterator is an iterator that can write a sequence of values. It is single-pass (old values of the iterator cannot be re-used), and write-only.
An output iterator represents a position in a (possibly infinite) 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 stated value type of the iterator (should be
void
for an output iterator that does not model some other
iterator concept).
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
The type Iter must be a model of Assignable.
The type ValueType must be a model of Assignable.
The type Iter must be a model of DefaultConstructible.
The type Iter must be a model of EqualityComparable.
category must be derived from std::output_iterator_tag, a model of DefaultConstructible, and a model of CopyConstructible.
difference_type must be a model of SignedInteger.
Name | Expression | Type | Precondition | Semantics | Postcondition |
---|---|---|---|---|---|
Dereference |
*i |
|
|||
Dereference and assign |
*i = x |
|
|
||
Preincrement |
++i |
Iter & |
|
||
Postincrement |
i++ |
|
Equivalent to |
|
|
Postincrement, dereference, and assign |
*i++ = x |
|
Equivalent to |
|