Boost C++ Libraries 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


#include <boost/exception_ptr.hpp>

    exception_ptr current_exception();


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


  • 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.




  • 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. If enable_current_exception was not used, and if the compiler does not provide the necessary support, then current_exception may return an exception_ptr that refers to an instance of unknown_exception. In this case, if the original exception object derives from boost::exception, then the boost::exception sub-object of the unknown_exception object is initialized by the boost::exception copy constructor.