Node:Input iterators, Next:Output iterators, Previous:Iterators, Up:Iterators
| X (const X& a) | Constructor on input iterators |
| == | Operator on input iterators |
| != | Operator on input iterators |
| * | Operator on input iterators |
| ++ | Operator on input iterators |
A class or a built-in type X satisfies the requirements of an input
iterator for the value type T if the following expressions are valid:
|
| expression | return type | operational semantics | assertion/note pre/post-condition
|
X(a) | X(a) is a copy of a.
note: a destructor is assumed. | ||
X u(a); X u = a; | post: u is a copy of a.
| ||
u = a | X& | post: u is a copy of a.
| |
a == b | convertible to bool | if a is a copy of b, then a == b returns
true.
== is an equivalence relation over the domain of
==.
| |
a != b | convertible to bool | !(a == b)
| |
*a | convertible to T | pre: a is dereferenceable.
if a is a copy of b,
then *a is equivalent to *b.
| |
++r | X& | pre: r is dereferenceable.
post: r is dereferenceable or r is past-the-end.
| |
(void)r++ | void | (void)++r
| |
*r++ | T |
{ X tmp = r;
++r;
return tmp; }
|
NOTE: For input iterators, there are no requirements on the type or
value of r++ beyond the requirement that
*r++ works appropriately. In
particular, r == s does not imply ++r == ++s. (Equality does
not guarantee the substitution property or referential transparency.) As
for ++r, there are no more requirements on
the values of any copies of r
except that they can be safely destroyed or assigned to. After executing
++r, copies of (the previous) r are not required
to be in the domain of
==. Algorithms on input iterators should never attempt to pass through
the same iterator twice. They should be single pass algorithms. Value
type T is not required to be an lvalue type. These algorithms can be
used with istreams as the source of the input data through the
istream_iterator class.