Frank Mori Hess wrote:
I've made some minor changes to shared_ptr.hpp and enable_shared_from_this.hpp as a proof of concept (diffs against boost 1.32 attached). It appears to work beautifully. The "real thing" would also take steps to make sure the postconstructor only gets called once (maybe in a "postconstructible" class derived from enable_shared_from_this. And the virtual function that is called in enable_shared_from_this might want a less specific name than postconstruct.
Peter, is there any chance a change like this could get put in shared_ptr?
I don't think adding polymorphism to something as widely used as enable_shared_from_this is an option. An alternative would be a smart pointer for exclusive use to track bound slot objects. That would also allow direct notification of the slot when the reference count drops to zero. The downside is again (actually worse than with trackable) that the entire client code must be made aware of the tracking. Regards Timmo Stange