You were redirected to || See search results for: "reverse_iterator"
class template


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

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

Member types

memberdefinition in reverse_iteratordescription
iterator_typeIteratorIterator's type
iterator_categoryiterator_traits<Iterator>::iterator_categoryPreserves Iterator's category
value_typeiterator_traits<Iterator>::value_typePreserves Iterator's value type
difference_typeiterator_traits<Iterator>::difference_typePreserves Iterator's difference type
pointeriterator_traits<Iterator>::pointerPreserves Iterator's pointer type
referenceiterator_traits<Iterator>::referencePreserves Iterator's reference type

Member functions

Non-member function overloads