...
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdexcept> class SomeClass { class Bad { bool has_error() const; public: ~Bad() noexcept(false) { if (has_error()) { throw std::logic_error("Something bad"); } } } bad_member; public: ~SomeClass() try { // ... } catch(...) { // Catch exceptions thrown from noncompliant destructors of // member objects or base class subobjects. // NOTE: Returning fromFlowing off the end of a destructor function-try-block causes // the caught exception to be implicitly rethrown, but an explicit // explicit return statement will prevent that from happening. return; } }; |
...