Deconstructors can’t throw
You cant throw an exception from a deconstruction method of a class because all destroy methods are noexcept(true).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include <iostream> class MyClass { public: MyClass() = default; ~MyClass() = default; }; int main() { MyClass a; // Deconstructions are noexept true std::cout << "Deconstruction status " << std::boolalpha << noexcept (a.~MyClass()) << std::endl; return EXIT_SUCCESS; } |
1 Response
[…] can’t throw an exception from deconstruction […]