X (const X& a) | Constructor on output iterators |
* | Operator on output iterators |
++ | Operator on output iterators |
A class or a built-in type
X satisfies the requirements
of an output iterator if the following expressions are valid:
Expression | Return type | Operational semantics | Assertion/note pre/post-condition |
X(a) | *a = t is equivalent to
*X(a) =
t. note: a destructor is assumed. | ||
X u(a); X u = a; |
|||
*a = t | result is not used |
||
++r | X& | ||
r++ | X or X& |
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 are not necessarily 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. In particular, the following two conditions should hold: first, any iterator value should be assigned through before it is incremented (this is, for an output iterator i, i++; i++; is not a valid code sequence); second,any value of an output iterator may have at most one active copy at any given time (for example, i = j; *++i = a; *j = b; is not a valid code sequence).
|
|