Figure 15.8 shows the predefined iterator typedef
s that are found in the Standard Library container class definitions. Not every typedef
is defined for every container. We use const
versions of the iterators for traversing const
containers or non-const
containers that should not be modified. We use reverse iterators to traverse containers in the reverse direction.
Fig. 15.8. Iterator typedefs.
Error-Prevention Tip 15.3
Operations performed on a const_iterator return references to const to prevent modification to elements of the container being manipulated. Using const_iterators where appropriate is another example of the principle of least privilege.
3.144.48.218