Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.

Boost Exception

current_exception

#include <boost/exception_ptr.hpp>

namespace
boost
    {
    exception_ptr current_exception();
    }

Requirements:

The current_exception function must not be called outside of a catch block.

Returns:

  • An exception_ptr that refers to the currently handled exception or a copy of the currently handled exception.
  • If the function needs to allocate memory and the attempt fails, it returns an exception_ptr that refers to an instance of std::bad_alloc.

Throws:

Nothing.

Notes:

  • It is unspecified whether the return values of two successive calls to current_exception refer to the same exception object.
  • Correct implementation of current_exception may require compiler support, unless enable_current_exception was used at the time the currently handled exception object was passed to throw. Whenever current_exception fails to properly copy the current exception object, it returns an exception_ptr to an object of type that is as close as possible to the original exception type, using unknown_exception as a final fallback. All such types derive from boost::exception, and: