C++ Iterator Library - bidirectional_iterator_tag



Description

It used to identify the category of an iterator as a bidirectional iterator and bidirectional iterator support at least one the following operations.

C++98

property valid expressions
It is a default-constructible, copy-constructible, copy-assignable and destructible

X a;

X b(a);

b = a;

It can be compared for equivalence using the equality/inequality operators

(meaningful when both iterator values iterate over the same underlying sequence).

a == b

a != b

It can be dereferenced as an rvalue (if in a dereferenceable state).

*a

a->m

For mutable iterators (non-constant iterators):

Can be dereferenced as an lvalue (if in a dereferenceable state).

*a = t

It can be incremented (if in a dereferenceable state).

The result is either also dereferenceable or a past-the-end iterator.

Two iterators that compare equal, keep comparing equal after being both increased.

++a

a++

*a++

It can be decremented (if a dereferenceable iterator value precedes it).

--a

a--

*a--

C++11

property valid expressions
It is a default-constructible, copy-constructible, copy-assignable and destructible

X a;

X b(a);

b = a;

It can be compared for equivalence using the equality/inequality operators

(meaningful when both iterator values iterate over the same underlying sequence).

a == b

a != b

It can be dereferenced as an rvalue (if in a dereferenceable state).

*a

a->m

For mutable iterators (non-constant iterators):

Can be dereferenced as an lvalue (if in a dereferenceable state).

*a = t

It can be incremented (if in a dereferenceable state).

The result is either also dereferenceable or a past-the-end iterator.

Two iterators that compare equal, keep comparing equal after being both increased.

++a

a++

*a++

It can be decremented (if a dereferenceable iterator value precedes it).

--a

a--

*a--

Lvalues are swappable. swap(a,b)

Declaration

Following is the declaration for std::bidirectional_iterator_tag.

C++11

struct bidirectional_iterator_tag {}
iterator.htm
Advertisements