Boost logo

Boost :

Subject: Re: [boost] [C++11] If you have an old class with a throwing destructor...
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2013-09-16 15:17:18


On Mon, Sep 16, 2013 at 5:12 AM, Jonathan Wakely
<jwakely.boost_at_[hidden]> wrote:
> On 9 September 2013 22:57, Niall Douglas wrote:
>> On 9 Sep 2013 at 13:11, Nevin Liber wrote:
>> The problem is that unless some code is specifically marked as
>> noexcept, you have to assume it can throw, and as destructors ought
>> to be noexcept, that means lots of try...catch verbiage.
> I disagree that littering destructors with try-catch is best practice.

Littering your code with throwing destructors is not the best practice, either.

The simple rule to follow is: don't ever throw in destructors. In
practice this means that destructors should free resources and do
nothing else. That way you don't litter destructors with try
catch(...), you use this only as a last resort means to prevent a
destructor from throwing.

-- 
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode

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