|
Boost : |
Subject: Re: [boost] scoped_ptr deleter
From: Stefan Strasser (strasser_at_[hidden])
Date: 2009-09-16 12:44:35
Am Wednesday 16 September 2009 16:15:11 schrieb Felipe Magno de Almeida:
> 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:
>
> [snip]
>
> the custom destruction can be shared through
> the application for use with allocators for example.
that's a valid point, but I'm still not sure if changing the type of a widely
used class whose ONLY purpose is to call "delete", and break some code, is
the right thing to do.
it would be a new pointer type. the only thing it has in common with
scoped_ptr is the pointer semantics.
and you could easily introduce a new type that makes this easy to build:
template<class T, class This>
class ptr; //part of boost
template<class T>
struct ogre_ptr : public ptr<T,ogre_ptr<This> >{
ogre_ptr(T *t) : ...
~ogre_ptr(){ delete ogre-style. }
};
>
> > 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
> technique.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk