Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixing a comment think-o

...

Code Block
bgColor#ccccff
langcpp
#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;
  }
};

...