I have a particular class that stores a piece of data, which implements an interface:
template
class MyContainer : public Container
If the usage is supposed to be similar to stdlib, then the iterator needs to be a value object, because it normally gets copied by value a lot. (Also, otherwise what would the begin
and end
method return a reference to?)
template
class Iterator
{
shared_ptr it;
public:
Iterator(shared_ptr);
T& operator*() { it->deref(); }
T* operator->() { return &it->deref(); }
Iterator& operator++() { it->inc(); return *this; }
etc.
};