I know there is no abstract base class for iterators in C++ but I have a specific question I can't find an answer to. In the documentation for list::begin() this example of iterating over list is given:
std::cout << "mylist contains:";
for (std::list<int>::iterator it=mylist.begin(); it != mylist.end(); ++it)
std::cout << ' ' << *it;
...
And for list::rbegin() this is given:
std::cout << "mylist backwards:";
for (std::list<int>::reverse_iterator rit=mylist.rbegin(); rit!=mylist.rend(); ++rit)
std::cout << ' ' << *rit;
...
Do I really have to specify that the iterator is a list iterator - std::list<int>::iterator? This means I can't generalize between iterators over the same type (say int) from different containers?! And further, do I really have to distinguish between a std::list::iterator and std::list::reverse_iterator? According to the documentation they are both ForwardIterators?
How can I avoid these qualifications? It seems against the whole point of having iterators.
template <class T, class U> void iterate_it(T<U>::iterator it);. I can't get that to compile.mylistcomes from)