|
Boost : |
Subject: Re: [boost] [exception] warning about non-virtual destructor - resolution?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2012-04-15 04:54:48
On Sunday 15 April 2012 09:46:19 Daniel James wrote:
> On 14 April 2012 22:30, Andrey Semashev <andrey.semashev_at_[hidden]> wrote:
> >
> > My understanding is that checked_delete is intended to protect against
> > freeing a pointer of an incomplete type, not against a missing virtual
> > destructor. It is a tool of itself which can be used outside shared_ptr
> > and in these cases a warning may be most appropriate. IMHO, if shared_ptr
> > aims to support valid behavior in the lack of a virtual destructor, it
> > should deal with the warnings itself.
>
> I don't think shared_ptr can do that. There are two places where the
> warning can be dealt with (the delete command and the deleted object),
> neither of which are part of shared_ptr. Unless I've missed something
> the only way it could deal with it without changing checked_delete is
> to use its own implementation of checked_delete. If shared_ptr can't
> use checked_delete then that suggests to me a real weakness in
> checked_delete. The solution *might* be to add another function to
> checked_delete that doesn't warn.
Using a separate implementation of checked_delete in shared_ptr is what I had
in mind. And this implementation should not be public, I think.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk