
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.