Jul 14, 2014

[C++11] destructor with noexcept

quote from Effective Modern C++:

By default, all memory deallocation functions and all destructors
—both user-defined and compiler-generated—
are implicitly noexcept.

There’s thus no need to declare them noexcept. (Doing so doesn’t hurt anything, it’s just unconventional.)

The only time a destructor is not implicitly noexcept is when a data member of the class (including inherited members and those contained inside other data members) is of a type that expressly states that its destructor may emit exceptions
(e.g., declares it “noexcept(false)”).

Such destructors are uncommon. There are none in the Standard Library.


--------
constexpr , noexcept are part of function interface.
and _Can't_ participate in function overload.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.