See what the master says:
Scott Myers in Effective STL
Point 26. Prefer iterator for iterator const, reverse_iterator and const_reverse_iterator. Although containers support four types of iterators, one of these types has privileges that others do not. This type is an iterator, an iterator is special.
typedef deque<int> IntDeque; //STL container and typedef lntDeque::iterator Iter; // iterator types are easier typedef lntDeque::const_iterator ConstIter; // to work with if you // use some typedefs Iter i; ConstIter ci; … //make i and ci point into // the same container if (i == ci ) ... //compare an iterator // and a const_iterator
Item 27. Use distance and forward to convert container constant constants to iterators.
typedef deque<int> IntDeque;
What works - advancement and distance
typedef deque<int> IntDeque;
source share