A ForwardIterator is an Iterator that can read data from the pointed-to element.
Unlike InputIterator and OutputIterator, it can be used in multipass algorithms.
Requirements
The type It satisfies ForwardIterator if.
- The type
ItsatisfiesInputIterator - The type
ItsatisfiesDefaultConstructible - Objects of the type
Itprovide multipass guarantee described below - The type
std::iterator_traits<It>::referencemust be exactly
-
-
T&ifItsatisfiesOutputIterator(Itis mutable) -
const T&otherwise (Itis constant),
-
- (where
Tis the type denoted bystd::iterator_traits<It>::value_type)
- Equality and inequality comparison is defined over all iterators for the same underlying sequence and the value initialized-iterators (since C++14).
And, given.
-
i, dereferenceable iterator of typeIt -
reference,the type denoted bystd::iterator_traits<It>::reference
The following expressions must be valid and have their specified effects.
| Expression | Return type | Equivalent expression | Notes |
|---|---|---|---|
i++ | It | It ip=i; ++i; return ip; | |
*i++ | reference |
A mutable ForwardIterator is a ForwardIterator that additionally satisfies the OutputIterator requirements.
Multipass guarantee
Given a and b, dereferenceable iterators of type It.
- If
aandbcompare equal (a == bis contextually convertible totrue) then either they are both non-dereferenceable or*aand*bare references bound to the same object - Assignment through a mutable
ForwardIteratoriterator cannot invalidate the iterator (implicit due toreferencedefined as a true reference) - incrementing a copy of
adoes not change the value read froma(formally, eitherItis a raw pointer type or the expression(void)++It(a), *ais equivalent to the expression*a) -
a == bimplies++a == ++b
Singular iteratorsA value-initializedForwardIterator behaves like the past-the-end iterator of some unspecified empty container: it compares equal to all value-initialized ForwardIterators of the same type. | (since C++14) |
Please login to continue.