[output.iterators] (original) (raw)
23 Iterators library [iterators]
23.3 Iterator requirements [iterator.requirements]
23.3.5 C++17 iterator requirements [iterator.cpp17]
23.3.5.4 Output iterators [output.iterators]
A class or pointer typeXmeets the requirements of an output iterator if X meets the Cpp17Iterator requirements ([iterator.iterators]) and the expressions in Table 86are valid and have the indicated semantics.
Table 86: 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 might not be defined.
— _end note_]