...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdexcept> class S { bool shouldhas_throwerror() const; public: ~S() noexcept(false) { // Normal processing if (shouldhas_throwerror()) { throw std::logic_error("Something bad"); } } }; |
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <exception> #include <stdexcept> class S { bool shouldhas_throwerror() const; public: ~S() { // Normal processing if (shouldhas_throwerror() && !std::uncaught_exception()) { throw std::logic_error("Something bad"); } } }; |
...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdexcept> class SomeClass { class Bad { bool shouldhas_throwerror() const; public: ~Bad() noexcept(false) { if (shouldhas_throwerror()) { throw std::logic_error("Something bad"); } } }; Bad bad_member; public: ~SomeClass() try { // ... } catch(...) { // Attempt to handle exceptions thrown from Bad destructor. } }; |
...