## Class exception_checker

boost::scope::exception_checker — A predicate for checking whether an exception is being thrown.

## Synopsis

    // In header: <boost/scope/exception_checker.hpp>

    class exception_checker {
    public:
      // types
      typedef bool result_type;  // Predicate result type.

      // public member functions
      exception_checker() noexcept;
      result_type operator()() const noexcept;
    };

## Description

On construction, the predicate captures the current number of uncaught exceptions, which it then compares with the number of uncaught exceptions at the point when it is called. If the number increased then a new exception is detected and the predicate returns `true`.

| Note
This predicate is designed for a specific use case with scope guards created on the stack. It is incompatible with C++20 coroutines and similar facilities (e.g. fibers and userspace context switching), where the thread of execution may be suspended after the predicate captures the number of uncaught exceptions and then resumed in a different context, where the number of uncaught exceptions has changed. Similarly, it is incompatible with usage patterns where the predicate is cached after construction and is invoked after the thread has left the scope where the predicate was constructed (e.g. when the predicate is stored as a class data member or a namespace-scope variable).

### `exception_checker` public member functions

1.     exception_checker() noexcept;

   Constructs the predicate.

   Upon construction, the predicate saves the current number of uncaught exceptions. This information will be used when calling the predicate to detect if a new exception is being thrown.

   Throws: Nothing.

2.     result_type operator()() const noexcept;

   Checks if an exception is being thrown.

   Throws: Nothing.

   Returns: | `true` if the number of uncaught exceptions at the point of call is greater than that at the point of construction of the predicate, otherwise `false`.