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

2.4 KiB

[iterator.concept.bidir]

24 Iterators library [iterators]

24.3 Iterator requirements [iterator.requirements]

24.3.4 Iterator concepts [iterator.concepts]

24.3.4.12 Concept bidirectional_iterator [iterator.concept.bidir]

1

#

The bidirectional_iterator concept adds the ability to move an iterator backward as well as forward.

templateconcept bidirectional_iterator =forward_iterator &&derived_from<ITER_CONCEPT(I), bidirectional_iterator_tag> &&requires(I i) {{ --i } -> same_as<I&>; { i-- } -> same_as; };

2

#

A bidirectional iterator r is decrementable if and only if there exists some q such that++q == r.

Decrementable iterators r shall be in the domain of the expressions--r and r--.

3

#

Let a and b be equal objects of type I.

I models bidirectional_iterator only if:

If a and b are decrementable, then all of the following are true:

addressof(--a) == addressof(a)

bool(a-- == b)

after evaluating both a-- and --b, bool(a == b) is still true

bool(++(--a) == b)

If a and b are incrementable, then bool(--(++a) == b).