Exceptions in destructors

In C++11 destructors default to noexcept so you have to go out of your way to make them throw. See throwing a vector in a destructor. #include <exception>#include <iostream>#include <vector> // Note the braces void exception1() try { throw 1; } catch (int e) { std::cout << "Caught " << e << std::endl; } catch (const std::out_of_range &oor) { std::cout << "Caught OOR\n" << oor.what() << std::endl; } catch (const std::exception &e) { std::cout << "Caught " << e. [Read More]