Subject: Re: [boost] scoped_ptr deleter
From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2009-09-16 10:15:11
On Wed, Sep 16, 2009 at 1:08 PM, Stefan Strasser <strasser_at_[hidden]> wrote:
> Am Wednesday 16 September 2009 16:01:00 schrieb Felipe Magno de Almeida:
> the point of a deleter is to execute CUSTOM code at destruction.
Or custom desallocation. Or anything else.
> using scoped_ptr (without deleter) automates deletion so you don't have to
> write custom code that does that.
So that you don't have to write anything actually. The same is true
for custom destruction, the custom destruction can be shared through
the application for use with allocators for example.
> that simplifies things a lot.
It does for delete and it does for custom deleters.
> but a scoped_ptr delete would provide the same thing as a destructor or a
> scope exit: execute custom code.
I don't understand why you think calling delete is so different from
any other kind of destruction. To me it is as custom as anything else.
> the only reason shared_ptr or unique_ptr do have deleters is because the point
> of destruction aren't statically known, as they can be copied or moved.
They do because it allows using other destruction strategy. Because
the point of destruction is unknown is because it uses a type erasure
-- Felipe Magno de Almeida