Boost logo

Boost Users :

From: João Abecasis (jpabecasis_at_[hidden])
Date: 2006-02-03 10:30:52


me22 wrote:
> One possibility, however, would be for a deleter_scoped_ptr ( that's
> not yet written ) to have a second template argument of a functor that
> would be default-constructed and then called on the pointer as the
> deleter. That would eliminate the speed and size overhead, but it
> means much less flexibility in what the deleter can be ( since it must
> be set at declaration, which means no binders or function pointers,
> among other things ).

FWIW, I've written a scoped_ptr that does just that. It's available from

     http://developer.berlios.de/projects/breeze/

No packaged release for now, just a public subversion repository you can
download from.

You'll find my scoped_ptr in breeze/scoped_ptr.hpp, as breeze::scoped_ptr

     template <
         class T,
         class Pointer = breeze::default_,
         class Reference = breeze::default_,
         class Deleter = breeze::default_
>
     struct breeze::scoped_ptr;

It does not offer the same thread-safety guarantees wrt to the deleter
as boost::shared_ptr does. As a substitute for boost::scoped_ptr,
however it should be safe. The deleter will be called in the same thread
as the destructor of the scoped_ptr.

HTH,

João


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net