shared_ptrget_deleter

I have got a shared_ptr use case where I use the Deleter to hold some extra data which I access through get_deleter. But now I would like to have custom deletion too, by subclassing from the common part. Then to access my data, I need get_deleter to work with superclass(es) of the actual deleter, not only with the exact type. Here is a simple suggestion to make it possible : in boost/detail/shared_count.cpp, introduce : template <class D> struct deleter_caster { void * operator()(std::type_info const & ti, D * del) const { return ti == typeid(D) : del : 0; } }; and make get_deleter implementation in sp_counted_base_impl as virtual void * get_deleter(std::type_info const & ti) { return deleter_caster<D>(ti, del); } Then I can specialize deleter_caster to my linking. D. Pierre
participants (1)
-
David Pierre