A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/iterator/ForwardIterator/ below:

class

<iterator>

std::forward_iterator_tag
struct forward_iterator_tag {};

Forward iterator category

Empty class to identify the category of an iterator as a forward iterator:

Forward iterators


Forward iterators are 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.

Performing operations on a forward iterator that is dereferenceable never makes its iterator value non-dereferenceable. This enables algorithms that use this category of iterators to use multiple copies of an iterator to pass more than once by the same iterator values.

All bidirectional and random-access iterators are also valid forward iterators.

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

property valid expressions Is default-constructible, copy-constructible, copy-assignable and destructible X a;
X b(a);
b = a;
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
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 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++
property valid expressions Is default-constructible, copy-constructible, copy-assignable and destructible X a;
X b(a);
b = a;
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
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 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)


Where X is a forward iterator type, a and b are objects of this iterator type, and t is an object of the type pointed by the iterator type (or some other type that can be assigned to the lvalue returned by dereferencing an object of type X).

Constant iterators are iterators that do not fulfill the requirements of an output iterator; Dereferencing them yields a reference to a constant element (such as const T&).

These properties are the same as those of bidirectional iterators, except that forward iterators only support being incremented (but not decreased).



See also
input_iterator_tag
Input iterator category (class)
output_iterator_tag
Output iterator category (class)
bidirectional_iterator_tag
Bidirectional iterator category (class)
random_access_iterator_tag
Random-access iterator category (class)
iterator
Iterator base class (class template)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4