Suppose I have a class that encapsulates a std container:
class Stash { list<int> Data; public: list<int>::const_iterator GetAccess() const { return Data.begin(); } };
This is a very convenient way to get the user to read data in the form of an iterator. However, I cannot find another way to compare the iterator with container.end()
. So, I would like to know if it is possible to do this only using stdlib, or should I write an iterator class myself (for example, using the can_advance
method).
This may be a relevant question, but it asks if the iterator is valid, and if it can move forward. I could not find any information about the latter.
source share