| 
 |  | 
Frequently it is necessary to iterate over a constant List.
(Think of implementing the stream insertion operation for Lists.)
Using a Listiter<T> for this is not possible,
since
Listiter<T> contains operations that change the
attached List.
In order to make it possible for
the user to iterate over a constant
List, there is a class Const_listiter.
Const_listiter provides all the operations of
Listiter, except for the operations that change
the attached List.
(Listiter
is actually derived from Const_listiter.)
Here is an example of iterating over a constant List.
The following is the actual definition of stream insertion for
List:
   ostream&
   operator<<(ostream& oo, const List<T>& ll) {
       int first = 1;
       oo << "( ";
       Const_listiter<T> l(ll);
       while (!l.at_end()) {
           if (!first)
                   oo << ", ";
           first = 0;
           oo << *(l.next());
       }
       oo << " )";
       return oo;
   }
The class List_of_piter has a similar analogue
in
Const_list_of_piter.