Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 2000-04-08 01:33:36


> Allowing exceptions to be thrown
>
> ... from a smart pointer destructor is another arguable choice.

I don't agree with this. Under the current language rules a destructor which
throws an exception doesn't complete. It is unclear what is to be done with
a partially-destroyed object. That almost makes it nonsense. This is totally
apart from the fact that program termination is likely.

> This can be
> problematic in situations where the destructor might be called because of
> another exception being thrown.  The behavior of std::auto_ptr is to allow any
> exceptions out from the destructor.

No, std::auto_ptr's destructor has an empty exception-specification, so no
exceptions will propagate out of it, ever.
 
> Allowing such exceptions can reduce the
> safety of using smart pointers. On the other hand, allowing such exceptions
> makes smart pointers behave more like automatic objects.

What does this mean? Can't a smart pointer be an automatic object?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk