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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Boost Exception


#include <boost/exception/enable_current_exception.hpp>

    template <class T>
    ---unspecified--- enable_current_exception( T const & e );


T must be a class with an accessible no-throw copy constructor.


An object of unspecified type which derives publicly from T. That is, the returned object can be intercepted by a catch(T &).


This function is designed to be used directly in a throw-expression to enable the exception_ptr support in Boost Exception. For example:

    public std::exception

throw boost::enable_current_exception(my_exception());

Unless enable_current_exception is called at the time an exception object is used in a throw-expression, an attempt to copy it using current_exception may return an exception_ptr which refers to an instance of unknown_exception. See current_exception for details.


Instead of using the throw keyword directly, it is preferable to call boost::throw_exception. This is guaranteed to throw an exception that derives from boost::exception and supports the exception_ptr functionality.