Vij wrote:
How can I check if an iterator is still valid and can be still
dereferenced ?
There is no (portable) way.
If you need to hand out handles to an object that might suddenly
disappear, you need to add an extra level of indirection. That is,
create a reference counted object that won't disappear until all the
references to it are gone, and have that object contain a pointer to the
real object.
For a well designed and widely tested implementation of such an idea,
see boost::shared_ptr and boost::weak_ptr.
<url: http://boost.org/libs/smart_ptr/smart_ptr.htm>
--
Alan Johnson