Boost Exception

throw_exception

#include <boost/throw_exception.hpp>

namespace
boost
    {
#ifdef BOOST_NO_EXCEPTIONS
    void throw_exception( std::exception const & e ); // user defined
#else
    template <class E>
    void throw_exception( E const & e );
#endif
    }

Requirements:

E must derive publicly from std::exception.

Effects:

  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • 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.

Note:

Under BOOST_NO_EXCEPTIONS, unless BOOST_EXCEPTION_DISABLE is also defined, users can examine the passed exception object using boost::get_error_info, or format an automatic diagnostic message using boost::diagnostic_information.