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/throw_exception.hpp>

    void throw_exception( std::exception const & e ); // user defined
    template <class E>
    void throw_exception( E const & e );


  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) throws an exception of unspecified type that derives publicly from E and from boost::exception.
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.


E must derive publicly from std::exception. E may or may not derive from boost::exception.


  • The emitted exception can be intercepted as E &, std::exception &, or boost::exception &.
  • The emitted exception supports boost::exception_ptr.
  • If BOOST_EXCEPTION_DISABLE is defined and BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) equivalent to throw e.