Boost Exception

enable_exception_cloning()

#include <boost/exception/enable_exception_cloning.hpp>

namespace
boost
    {
    template <class T>
    ---unspecified--- enable_exception_cloning( T const & e );
    }

Requirements:

T must have an accessible no-throw copy constructor

Returns:

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

Description:

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

class
my_exception:
    public std::exception
    {
    };

....
throw boost::enable_exception_cloning(my_exception());

Unless enable_exception_cloning() is called at the time an exception object is used in a throw-expression, any attempt to copy it using clone_exception() returns an exception_ptr which refers to an instance of unknown_exception.

Note:

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

See also: