24 Iterators library [iterators]

24.2 Iterator requirements [iterator.requirements]

24.2.4 Output iterators [output.iterators]

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

Table 108 — Output iterator requirements (in addition to Iterator)
ExpressionReturn typeOperationalAssertion/note
semanticspre-/post-condition
*r = o result is not used Remark: After this operation r is not required to be dereferenceable.
post: r is incrementable.
++r X& &r == &++r.
Remark: After this operation r is not required to be dereferenceable.
post: r is incrementable.
r++ convertible to const X& { X tmp = r;
++r;
return tmp; }
Remark: After this operation r is not required to be dereferenceable.
post: r is incrementable.
*r++ = o result is not used Remark: After this operation r is not required to be dereferenceable.
post: r is incrementable.

Note: 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. Algorithms on output iterators should never attempt to pass through the same iterator twice. They should be single pass algorithms. Equality and inequality might not be defined. Algorithms that take output iterators can be used with ostreams as the destination for placing data through the ostream_iterator class as well as with insert iterators and insert pointers.  — end note ]