cplusplus.com
C++ : Reference : Miscellaneous : iterator : Forward Iterator
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
iterator
advance
back_inserter
distance
front_inserter
inserter
iterator
iterator_traits
iterator categories:
Bidirectional Iterator
Forward Iterator
Input Iterator
Output Iterator
Random Access Iterator
predefined iterators:
back_insert_iterator
front_insert_iterator
insert_iterator
istreambuf_iterator
istream_iterator
ostreambuf_iterator
ostream_iterator
reverse_iterator


Forward Iterator

<iterator>

Forward iterator category

Forward


Forward iterators are iterators especially designed for sequential access, where the algorithm passes through all the elements in the range from the beginning to the end.

There is not a single type of forward iterator: Each container defines its own specific iterator type able to iterate through it and access its elements. But all forward iterators support -at least- the following operations:

characteristicvalid expressions
Can be default-constructedX a;
X()
Can be copied and copy-constructedX b(a);
b = a;
Accepts equality/inequality comparisons.
Equal iterators imply the same element is pointed
a == b
a != b
Can be dereferenced (when not null)*a
a->m
Can be incremented (when not null)++a
a++
*a++
Where X is an iterator type, and a and b are objects of this iterator type.

These characteristics are the same of bidirectional iterators, except that forward iterators only support increment and not decrement.

See also