How can I have a Foo* iterator to a vector of Foo?

Posted by mghie on Stack Overflow See other posts from Stack Overflow or by mghie
Published on 2010-05-27T22:46:17Z Indexed on 2010/05/27 22:51 UTC
Read the original article Hit count: 143

Filed under:
|

If I have a class that contains a std::list<Foo>, how can I implement iterators to a Foo* collection, preferably without using boost?

I'd rather not maintain a parallel collection of pointers. For now I have std::list<Foo>, mostly so that removing or inserting an element does not invalidate all other iterators, but would it be possible to implement other iterators too, so that the collection type used in the implementation is opaque to the user of the class?

© Stack Overflow or respective owner

Related posts about c++

Related posts about iterator