I have an inheritance structure of objects with begin() and end() as pure virtual member functions in the base class. From this objects I’m planning to build a composite structure. This inner objects have std::vector member the begin() and end() get their data from. But in a leaf class there is no vector. Now I try to find a return value for begin() and end() in the leaf classes. What would be a good way to do that?
The easiest way would be to have a vector member in the leaf classes with no elements in it to fuel begin() and end(), but this just doesn’t feel right.
You could implement a very simple iterator class inside your leaf class that simply return dummy iterators. E.g. the begin() returns the same iterator as is returned by end(). You will need to implement some comparison functions as well. I’m not quite sure how std::iterator deals with this, but maybe that has some things you need.