Boost logo

Boost :

Subject: Re: [boost] [shared_ptr] Where is the bug?
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-10-03 16:11:49

----- Original Message -----
From: "Emil Dotchevski" <emil_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, October 03, 2008 8:32 PM
Subject: Re: [boost] [shared_ptr] Where is the bug?

> On Fri, Oct 3, 2008 at 9:08 AM, vicente.botet <vicente.botet_at_[hidden]>
> wrote:
>> Yes, I know. I was not wondering about why the X's destructor is not run
>> when deleting b, but why the X's destructor is called when deleting ptr.
> Because shared_ptr captures the destructor at the time it takes
> ownership of the object. If this happens when the object is being
> created (as in your example) the correct destructor is called even if
> it isn't virtual.
> It is common for base types that are designed to be managed by
> shared_ptr to use protected, non-virtual destructor (watch out for
> retarded gcc warnings.)

Thanks for your post,

What is the advantage to use protected destructor when used with shared
pointers? Shouldn't you have a deleter functor?


Boost list run by bdawes at, gregod at, cpdaniel at, john at