Iterators are the glue

Without iterators, there would be no way for us to move through the container and alter it according the algorithm. Hence, the iterator forms the backbone of this is process.

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 chapter on Iterators. 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.

Get hands-on with 1000+ tech skills courses.