A reverse iterator is an iterator that traverses a container backward, from the last element toward the first. A reverse iterator inverts the meaning of increment (and decrement). Incrementing (
++it) a reverse iterator moves the iterator to the previous element; derementing
(--it) moves the iterator to the next element.
The containers, aside from
forward_list, all have reverse iterators. We obtain a reverse iterator by calling the
crend members. These members return reverse iterators to the last element in the container and one “past” (i.e., one before) the beginning of the container. As with ordinary iterators, there are both
const and non
const reverse iterators.
Figure 10.1 illustrates the ...