class
<iterator>

std::output_iterator_tag

struct output_iterator_tag {};
Output iterator category
Empty class to identify the category of an iterator as an output iterator:

Output iterators


Output iterators are iterators that can be used in sequential output operations, where each element pointed by the iterator is written a value only once and then the iterator is incremented.

All forward, bidirectional and random-access iterators that are not constant iterators are also valid output iterators.

There is not a single type of output iterator: Each container may define its own specific iterator type able to iterate through it and access its elements. But all output iterators support -at least- the following operations:

propertyvalid expressions
Is copy-constructible, copy-assignable and destructibleX b(a);
b = a;
Can be dereferenced as an lvalue (if in a dereferenceable state).
It shall only be dereferenced as the left-side of an assignment statement.
Once dereferenced, its iterator value may no longer be dereferenceable.
*a = t
Can be incremented.++a
a++
*a++ = t
propertyvalid expressions
Is copy-constructible, copy-assignable and destructibleX b(a);
b = a;
Can be dereferenced as an lvalue (if in a dereferenceable state).
It shall only be dereferenced as the left-side of an assignment statement.
Once dereferenced, its iterator value may no longer be dereferenceable.
*a = t
Can be incremented.++a
a++
*a++ = t
Lvalues are swappable.swap(a,b)

Where X is an output iterator type, a and b are objects of this iterator type, and t is an object of the type pointed by the iterator type (or some other type that can be assigned to the lvalue returned by dereferencing an object of type X).

Algorithms requiring output iterators should be single-pass output algorithms: each iterator position is dereferenced once at most.

See also