Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#Actuall0calh05t

Posted 21 August 2013 - 02:14 AM

Note that throwing an exception from a destructor is also super bad mojo in C++. Basically any exception guarantees go out the window if you have destructors that throw. It's sufficiently bad that C++11 gave all destructors an implicit noexcept exception specification, meaning that an exception from a destructor will immediately call terminate() unless you specifically enable exceptions for the destructor for the class or one of the subobjects of that class contains a destructor which has exception enabled destructors.


Since all guarantees go out of the window if you throw in the destructor it is a *good thing* that destructors are marked noexcept, that way you have a guarantee that terminate is called, which I'll take over all kinds of undefined behavior (which throwing in the destructor will cause when used in conjunction with pretty much any library class or template which doesn't expect that... which includes all standard containers) any day.

#1l0calh05t

Posted 21 August 2013 - 02:08 AM

Note that throwing an exception from a destructor is also super bad mojo in C++. Basically any exception guarantees go out the window if you have destructors that throw. It's sufficiently bad that C++11 gave all destructors an implicit noexcept exception specification, meaning that an exception from a destructor will immediately call terminate() unless you specifically enable exceptions for the destructor for the class or one of the subobjects of that class contains a destructor which has exception enabled destructors.


Since all guarantees go out of the window if you throw in the destructor it is a *good thing* that destructors are marked noexcept, that way you have a guarantee that terminate is called, which I'll take over all kinds of undefined behavior (which throwing in the destructor will cause when used with pretty much any library class or template which doesn't expect that) any day.

PARTNERS