C++ Iterator Library - forward_iterator_tag



Description

It is an iterators that can be used to access the sequence of elements in a range in the direction that goes from its beginning towards its end.

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 when both are increased.

++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 when both are increased.

++a

a++

*a++

Lvalues are swappable. swap(a,b)

Declaration

Following is the declaration for std::forward_iterator_tag.

C++11

struct forward_iterator_tag {};
iterator.htm
Advertisements