class is not nothrow constructible but is nothrow destructible
Solution 1:
Destructors are special. For the implicit destructor as well as user-declared destructors without noexcept
specification, the destructor is noexcept(true)
by default if all destructors of members and base classes are noexcept(true)
.
To get a potentially-throwing destructor, you need to explicitly declare it noexcept(false)
. This is however generally not what one wants, since there will be trouble if the destructor throws while stack unwinding from another exception is in progress.
For ordinary functions, usually the default is noexcept(false)
, meaning potentially-throwing, if not declared otherwise.
There are a few additional special cases of this kind though, e.g. deallocation functions and (member) functions defaulted on their first declaration.