Boost logo

Boost :

Subject: Re: [boost] [C++11] If you have an old class with a throwing destructor...
From: Jonathan Wakely (jwakely.boost_at_[hidden])
Date: 2013-09-16 11:19:46


On 16 September 2013 14:54, Neil Groves wrote:
>
> The use of an explicit try-catch block is rarely the optimal solution
> in a destructor. I don't think we should consider recommending this
> practice. I am open to exploring the potential solutions involving
> decorating the destructor declarations/definitions to improve
> behaviour across compiler versions. I am unclear about how clever the
> C++11 has_trivial_destructor meta-functions are. Do they generally
> work when an explicitly defined noexcept destructor is declared?

I don't know about in general, but libstdc++'s does, yes. It's
basically implemented in terms of noexcept(std::declval<T&>().~T())
which will do the right thing when the destructor has an explicit
noexcept spec. If the destructor has an implicit exception spec then
whether is_nothrow_destructible gives the correct answer depends on
whether the compiler correctly implements the C++11 rule for implicit
exception specs on destructors.


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