25
Iterators library
[iterators]
25.3
Iterator requirements
[iterator.requirements]
25.3.4
Iterator concepts
[iterator.concepts]
25.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
.
template
<
class
I
>
concept
bidirectional_
iterator
=
forward_
iterator
<
I
>
&
&
derived_
from
<
ITER_CONCEPT
(
I
)
, bidirectional_iterator_tag
>
&
&
requires
(
I i
)
{
{
-
-
i
}
-
>
same_
as
<
I
&
>
;
{
i
-
-
}
-
>
same_
as
<
I
>
;
}
;
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:
(3.1)
If
a
and
b
are decrementable, then all of the following are
true
:
(3.1.1)
addressof
(
-
-
a
)
=
=
addressof
(
a
)
(3.1.2)
bool
(
a
-
-
=
=
b
)
(3.1.3)
after evaluating both
a
-
-
and
-
-
b
,
bool
(
a
=
=
b
)
is still
true
(3.1.4)
bool
(
+
+
(
-
-
a
)
=
=
b
)
(3.2)
If
a
and
b
are incrementable, then
bool
(
-
-
(
+
+
a
)
=
=
b
)
.