
"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:48178BBA.3050100@providere-consulting.com... [...]
I'm thinking that the cleanest solution will be to have set deletion split the cleanup into first calling all the objects' destructors and then freeing all the memory. When the objects are destroyed you should increment the reference count to make sure that the objects are not destroyed again. When you actually release the memory you can then verify that the reference count is 1, and thus that all references to the object come from within the set.
Otherwise, looking at your current implementation, it looks like shifted_ptr's on the heap will never clean up the object pointed to until the set goes away.
That's funny because actually I forgot adding a U<T>::reset() statement before set::release() inside shifted_ptr::release() in the code I submitted yesterday. I wanted to change it quickly but not on time. Now the first element in the set being deleted is the one pointed to by po_; -Phil