Boost logo

Boost :

Subject: Re: [boost] scoped_ptr deleter
From: Berserker (berserker_r_at_[hidden])
Date: 2009-09-22 03:18:06


> I didn't blame it. And I don't consider my example difficult, anyway. It
> provides a nice abstraction from the actual pointer type while not
> introducing excessive genericity. I can't remember the exact code but I
> surely used such technique somewhere in my code. Not sure it involved
> scoped_ptr, though...

What's the status about this? If we don't want to "break" the interface,
  we can always provide an option to enable this feature, something like
(same for scoped_array):

template<class T
#ifdef BOOST_SCOPED_PTR_ENABLE_DELETER
, class D = boost::checked_deleter<T> >
#endif
class scoped_ptr
{
// ...

public:
    ~scoped_ptr()
   {
      // ...

#ifdef BOOST_SCOPED_PTR_ENABLE_DELETER
      deleter()(ptr);
#else
      boost::checked_delete(ptr);
#endif
   }
};

BOOST_SCOPED_PTR_ENABLE_DELETER is not defined by default.
There are lots of samples like this in other boost libraries, is it
reasonable?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk