Iterators are the glue
Iterators define the range of the container on which the algorithms work. They describe a half-open range. In a half-open range the begin iterator points to the beginning, and the end iterator points to one position after the range.
The iterators can be categorized based on their capabilities. See the Categories section of the Iterators chapter. The algorithms provide conditions to the iterators. Like in the case of std::rotate
, most of the times a forward iterator is sufficient. But that doesn’t hold for std::reverse
. std::reverse
requires a bidirectional iterator.