A class or pointer type X satisfies the requirements of a forward iterator if
X satisfies the requirements of an input iterator ([input.iterators]),
X satisfies the DefaultConstructible requirements ([utility.arg.requirements]),
if X is a mutable iterator, reference is a reference to T; if X is a const iterator, reference is a reference to const T,
the expressions in Table [tab:iterator.forward.requirements] are valid and have the indicated semantics, and
objects of type X offer the multi-pass guarantee, described below.
The domain of == for forward iterators is that of iterators over the same underlying sequence.
Two dereferenceable iterators a and b of type X offer the multi-pass guarantee if:
a == b implies ++a == ++b and
X is a pointer type or the expression (void)++X(a), *a is equivalent to the expression *a.
[ Note: The requirement that a == b implies ++a == ++b (which is not true for input and output iterators) and the removal of the restrictions on the number of the assignments through a mutable iterator (which applies to output iterators) allows the use of multi-pass one-directional algorithms with forward iterators. — end note ]
Expression | Return type | Operational | Assertion/note |
semantics | pre-/post-condition | ||
r++ | convertible to const X& |
{ X tmp = r; ++r; return tmp; } | |
*r++ | reference |
If a and b are equal, then either a and b are both dereferenceable or else neither is dereferenceable.
If a and b are both dereferenceable, then a == b if and only if *a and *b are bound to the same object.