If you shouldn’t throw exceptions in a destructor, how do you handle errors in it?
Throwing an exception out of a destructor is dangerous. If another exception is already propagating the application will terminate. #include <iostream> class Bad { public: // Added the noexcept(false) so the code keeps its original meaning. // Post C++11 destructors are by default `noexcept(true)` and // this will (by default) call terminate if an exception … Read more