[output.iterators]

24 Iterators library [iterators]

24.3 Iterator requirements [iterator.requirements]

24.3.5 C++17 iterator requirements [iterator.cpp17]

24.3.5.4 Output iterators [output.iterators]

A class or pointer type X meets the requirements of an output iterator if X meets the Cpp17Iterator requirements ([iterator.iterators]) and the expressions in Table 80 are valid and have the indicated semantics.

Table 80 — Cpp17OutputIterator requirements (in addition to Cpp17Iterator) [tab:outputiterator]

Expression

Return type

Operational

Assertion/note

semantics

pre-/post-condition

*r = o

result is not used

Remarks: After this operation r is not required to be dereferenceable.

Postconditions: r is incrementable.

++r

X&

addressof(r) == addressof(++r).

Remarks: After this operation r is not required to be dereferenceable.

Postconditions: r is incrementable.

r++

convertible to const X&

{ X tmp = r;
++r;
return tmp; }

Remarks: After this operation r is not required to be dereferenceable.

Postconditions: r is incrementable.

*r++ = o

result is not used

Remarks: After this operation r is not required to be dereferenceable.

Postconditions: r is incrementable.

Recommended practice: The implementation of an algorithm on output iterators should never attempt to pass through the same iterator twice; such an algorithm should be a single-pass algorithm.

[Note 1:

The only valid use of an operator* is on the left side of the assignment statement.

Assignment through the same value of the iterator happens only once.

Equality and inequality are not necessarily defined.

— end note]