$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2005-01-06 08:25:28
Pablo Aguilar wrote:
> Thanks for your reply...
> 
> You're right, "reset" would delete the pointer... but when you're getting 
> rid of a pointer obtained from a factory, like I was in my case, pointers 
> don't always get disposed of using delete, but rather another function (like 
> p->release())
> 
> And rather than writing special purpose smart pointers for each type of 
> deleting function (p->dispose(), p->release(), api_function_free(p), etc..) 
> you can use shared_ptr with a custom deleter (here: 
> mem_fn(&pointer_type::dispose) or bind(&api_function_free, _1))
In some cases you can avoid the space and time overhead of shared_ptr by 
using a smart pointer template for which the custom deleter is a 
template argument.  In fact you can get even more general than that 
quite easily; I have a class template called auto_handle which with 
minimal work can be used to encapsulate all kinds of things with custom 
deleters, including Windows handles and POSIX file descriptors.
Ben.