Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2003-08-18 20:21:39

Glen Knowles <gknowles_at_[hidden]> writes:

> From: Victor A. Wagner, Jr. [mailto:vawjr_at_[hidden]]
>>At Monday 2003-08-18 14:43, you wrote:
>>>What's the rational for the requirement that ~pointee() be no throw?
> Instead
>>>of nothrow could it have been specified that shared_ptr functions throw
> only
>>>if ~pointee() throws?
>>>This is also something that could go in the docs (assuming I didn't simply
>>>miss it).
>>the ramifications of having any destructor throw are too horrible to
>>Well, maybe not "too horrible" but several articles have been written on
>>the ensuing problems.
> This may be true, and I have read a few articles on the subject, but
> "too horrible to comtemplate" isn't exactly a rational.

The shared_ptr docs are the wrong place for that, because similar
requirements that user-supplied types have non-throwing destructors
exist in most template code anywhere. Indeed, it's an implicit
assumption of nearly all of the Boost libraries, which should probably
be spelled out explicitly in one place. It isn't the smart pointer
library's job, nor even Boost's job to explain this general principle

> A simple statement in the common requirements that it is deemed too
> error prone would be helpful.

But it wouldn't be accurate. Having a throwing destructor is not just
prone to errors; it *is* an error (except in a very few special cases
which could probably be handled better in another way).

Dave Abrahams
Boost Consulting

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at