A RetroSearch Logo

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

Search Query:

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

class template

<iterator>

std::reverse_iterator
template <class Iterator> class reverse_iterator;

Reverse iterator


This class reverses the direction in which a bidirectional or random-access iterator iterates through a range.

A copy of the original iterator (the base iterator) is kept internally and used to reflect the operations performed on the reverse_iterator: whenever the reverse_iterator is incremented, its base iterator is decreased, and vice versa. A copy of the base iterator with the current state can be obtained at any time by calling member base.

Notice however that when an iterator is reversed, the reversed version does not point to the same element in the range, but to the one preceding it. This is so, in order to arrange for the past-the-end element of a range: An iterator pointing to a past-the-end element in a range, when reversed, is pointing to the last element (not past it) of the range (this would be the first element of the reversed range). And if an iterator to the first element in a range is reversed, the reversed iterator points to the element before the first element (this would be the past-the-end element of the reversed range).



Template parameters
Iterator
A bidirectional iterator type.
Or a random-access iterator, if an operator that requires such a category of iterators is used.

Member types member definition in reverse_iterator description iterator_type Iterator Iterator's type iterator_category iterator_traits<Iterator>::iterator_category Preserves Iterator's category value_type iterator_traits<Iterator>::value_type Preserves Iterator's value type difference_type iterator_traits<Iterator>::difference_type Preserves Iterator's difference type pointer iterator_traits<Iterator>::pointer Preserves Iterator's pointer type reference iterator_traits<Iterator>::reference Preserves Iterator's reference type
Member functions
(constructor)
Constructs reverse_iterator object (public member function)
base
Return base iterator (public member function)
operator*
Dereference iterator (public member function)
operator+
Addition operator (public member function)
operator++
Increment iterator position (public member function)
operator+=
Advance iterator (public member function)
operator-
Subtraction operator (public member function)
operator--
Decrease iterator position (public member function)
operator-=
Retrocede iterator (public member function)
operator->
Dereference iterator (public member function)
operator[]
Dereference iterator with offset (public member function)

Non-member function overloads
relational operators
Relational operators for reverse_iterator (function template)
operator+
Addition operator (function template)
operator-
Subtraction operator (function 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