From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-03-15 13:50:01


Frank Mori Hess wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Thursday 15 March 2007 13:23 pm, Peter Dimov wrote:
>> Frank Mori Hess wrote:
>>> I think the _exp_throwable class in Peter's prototype implementation
>>> of exception_ptr needs its destructor to be declared virtual.
>>
>> I don't think so. :-)
>
> I don't understand. Won't the exception_ptr deleter delete
> _exp_throwable_impl objects through base class _exp_throwable
> pointers?

No. If you try to delete an _exp_throwable*, you'll see that the protected
destructor won't allow that.

> Is there some magic here I'm missing?

Yes. The magic is inside shared_ptr<T>. It deletes whatever is passed to its
constructor, regardless of T, which can even be incomplete (as in this case)
or void.