Hello,
is it possible to derive from std::vector and derive also its iterator?
If I do it like in the example below, I get a problem when I need the begin
of the vector:
begin() returns the derived iterator. I need the derived iterator in order
to overload the operator++. But I want to use also
std::vector<PBaseItem>::begin() in order to get the begin of the vector.
But this function delivers the iterator of the base class. Is there any way
to solve this? (One way would be to use a begin which uses a pointer to an
iterator).
Example:
class CBaseItem;
// PBaseItem is a smart pointer pointing to a class CBaseItem:
typedef boost::intrusive_ptr<CBaseItem> PBaseItem;
class CBaseItemVector : public std::vector<PBaseItem> {
public:
CBaseItemVector(){};
virtual ~CBaseItemVector(){};
class iterator : public std::vector<PBaseItem> {
public:
iterator (){};
virtual ~iterator(){};
virtual PBaseItem operator*();
virtual void operator++();
virtual void operator++(int);
};
virtual iterator begin();
};
I would be interested if someone could give me a hint.
Greetings
Ernst
--
Ernst Murnleitner
www.awite.com