Are Destructors Noexcept by Default?

Any user-defined destructor is noexcept(true) by default, unless the declaration specifies otherwise, or the destructor of any base or member is noexcept(false) .

Are destructors implicitly Noexcept?

An implicit declaration of a destructor is considered to be noexcept(true) according to [except. spec], paragraph 14. As such, destructors must not be declared noexcept(false) but may instead rely on the implicit noexcept(true) or declare noexcept explicitly.

Why are destructors Noexcept?

Throwing an exception from a destructor results in undefined behavior, meaning that your program could be terminated abruptly without neatly destroying others objects. Thus destructors should never throw exceptions. Instead, they should catch and handle those thrown by the functions they call, and be noexcept .

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.