
On 10/23/2012 09:16 PM, TONGARI wrote:
Just provide it with your custom Deleter in the ctor.
template<class Y, class D> shared_ptr(Y * p, D d); OK, thanks.
However - this does require every construction of a shared pointer to be passed that destructor - that seems error prone if it is known that all T must be released by a given call. If shared_ptr defined a release function: template <typename T> class shared_ptr { ... void Release(T *t) { delete(t);} } and used Release where it currently deletes the object, then in a case like mine, all you'd have do to is specialize it: template <> shared_ptr<xmlDoc>::Release(xmlDoc *t) { xmlFreeDoc(t);} and then all shared_ptr<xmlDoc> would correctly release the object. I guess what I can do to avoid the risk would be to derive from shared_ptr and provide the destructor in my ctor.