Node:Forward iterators, Next:Bidirectional iterators, Previous:Output iterators, Up:Iterators
| X () | Constructor on forward iterators |
| X (const X& a) | Constructor on forward iterators |
| == | Operator on forward iterators |
| != | Operator on forward iterators |
| * | Operator on forward iterators |
| ++ | Operator on forward iterators |
A class or a built-in type X satisfies the requirements of a forward
iterator if the following expressions are valid:
|
| expression | return type | operational semantics | assertion/note pre/post-condition
|
X u; | note: u might have a singular value.
note: a destructor is assumed. | ||
X() | note: X() might be singular.
| ||
X(a) | a == X(a).
| ||
X u(a);
X u = a;
| X u; u = a;
| post: u == a.
| |
a == b | convertible to bool | == is an equivalence relation.
| |
a != b | convertible to bool | !(a == b)
| |
r = a | X& | post: r == a.
| |
*a | convertible to T | pre: a is dereferenceable.
a == b implies *a == *b.
If X is mutable, *a = t is valid.
| |
++r | X& | pre: r is dereferenceable.
post: r is dereferenceable or r is past-the-end.
r == s and r is dereferenceable
implies ++r == ++s.
&r == &++r.
| |
r++ | X |
{ X tmp = r;
++r;
return tmp; }
|
NOTE: The fact that r == s implies ++r == ++s
(which is not true for
input and output iterators) and the removal on the restrictions on the
number of the assignments through the iterator (which applies to output
iterators) allows the use of multi-pass one-directional algorithms with
forward iterators.