Search code examples
c++c++11iteratorstdlist

Check if std::list iterator is at end without access to the container


In a function, I work with a std::list<Type>::const_iterator. I don't have access to the container.

Is there a way to check if the iterator point to an accessible element (i.e. the iterator is not at the end of the container) ?

Note: I use C++11 (I don't want solution for C++ >= 14)


Solution

  • No.

    An iterator devoid of context is useless. Usually you will have a pair of iterators, denoting the range of interest.