A key factor in the design of STL is the consistent use of iterators, which generalize C++ pointers, as intermediaries between algorithms and containers. A precise classification of iterators into five categories is the basis for determining which algorithms can be used with which containers, and is the main guide to extension of the library to include new algorithms that work with STL containers, or new containers to which many STL generic algorithms can be applied.
The scheme used to determine which algorithms and containers can be combined consists of three parts:
ITERATOR CATEGORIES
All three categories also provide for
In addition to the requirements about how these operations are expressed, there are laws that they must obey. Without going into the full statement of the laws here, let us note that
Any C++ pointer type, T*, obeys all the laws of the random access iterator category.
There are two other categories, input iterators and output iterators, which are like forward iterators except not all properties of forward iterators are guaranteed.
CATEGORY OF ITERATORS PROVIDED BY EACH STL CONTAINER TYPE