On Mon, 21 Feb 2005 03:26:59 -0600, Jeremy Hill
Greetings,
However, I'm not quite sure how to 'deallocate' shared_ptrs that are in a Container, such as a vector. I'd like to issue some pseudocode to help put things in perspective:
<snip>
There is the class 'Descriptor' that is contained within a shared_ptr, which is wrapped in the 'Desc_broker' class. Once a Descriptor is invalidated, such as in fun_1() above, it is no longer needed. I'll need to get rid of invalid Descriptors before the vector is iterated through in fun_2(). However, since the shared_ptr for the invalid Descriptor will not go out of scope, to the best of my knowledge I'll need to help it along by using something along the lines of 'cleanup', which will remove all desc_ptrs whose Descriptors are invalid (via std::remove_if and the InvalidDesc predicate).
Thank you, Jeremy Hill
I think you'll find that the shared_ptr is destructed when you do the erase, so you're OK... Put some sort of trace in your Descriptors destructor to verify (for yourself) that this is the case. HTH Stuart Dootson