Ernst Murnleitner wrote:
Hello,
I use boost::shared pointers and store them in a std::list. Now, I have some iterators which are stored in other classes. If items are inserted or deleted, the iterators become invalid. Is there a mechanism in the
std::list iterators will only be invalidated if the item to which the iterator refers is erased.
boost::libraries in order to update these iterators (e.g. iterators, containers)?
Nothing that I know of that directly supports that sort of design. That's what shared_ptr's are for. Store the shared_ptr and the std::list& (or a shared_ptrstd::list if the lifetime is not guaranteed), then use std::find( list.begin(), list.end(), mysharedptr ) to get an iterator. Or you might look into using the new multi_index library, storing a key rather than an iterator. Jeff Flinn