Files
2025-10-25 03:02:53 +03:00

3.0 KiB

[iterator.concept.forward]

24 Iterators library [iterators]

24.3 Iterator requirements [iterator.requirements]

24.3.4 Iterator concepts [iterator.concepts]

24.3.4.11 Concept forward_iterator [iterator.concept.forward]

1

#

The forward_iterator concept adds copyability, equality comparison, and the multi-pass guarantee, specified below.

templateconcept forward_iterator =input_iterator &&derived_from<ITER_CONCEPT(I), forward_iterator_tag> &&incrementable &&sentinel_for<I, I>;

2

#

The domain of == for forward iterators is that of iterators over the same underlying sequence.

However, value-initialized iterators of the same type may be compared and shall compare equal to other value-initialized iterators of the same type.

[Note 1:

Value-initialized iterators behave as if they refer past the end of the same empty sequence.

— end note]

3

#

Pointers and references obtained from a forward iterator into a range [i, s) shall remain valid while [i, s) continues to denote a range.

4

#

Two dereferenceable iterators a and b of type X offer the multi-pass guarantee if

a == b implies ++a == ++b and

the expression((void)[](X x){++x;}(a), *a) is equivalent to the expression *a.

5

#

[Note 2:

The requirement thata == b implies++a == ++b and the removal of the restrictions on the number of assignments through a mutable iterator (which applies to output iterators) allow the use of multi-pass one-directional algorithms with forward iterators.

— end note]