On 9 September 2013 11:52, Niall Douglas
On 9 Sep 2013 at 18:41, Andrzej Krzemienski wrote:
Your analysis is correct, but in practice the problem described by Daryle still exists. Authors of classes that throw in destructors need to take some action if they have written their libraries in C++03: either mark destructors as noexcept(false) or embed a sub-object (member or base class) that has a noexcept(false) destructor.
In C++03 it was always best practice to *always* wrap your destructors in a try...catch clause.
No; the best practice is not to throw from a destructor.
As an aside, we could really do with some new compiler warnings on this actually.
I'm not sure what the warning would be, as move constructors are allowed to throw.
I already get caught enough times forgetting to mark move constructors as noexcept, without which some STL implementations will silently disable move construction completely.
That seems buggy, other than the well-defined cases such as vector using the equivalent of move_if_noexcept under the covers when growing a vector. -- Nevin ":-)" Liber mailto:nevin@eviloverlord.com (847) 691-1404