#include <boost/exception/enable_current_exception.hpp>
namespace
boost
{
template <class T>
---unspecified--- enable_current_exception( T const & e );
}
T must have 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 cloning support in Boost Exception. For example:
class
my_exception:
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, any attempt to copy it using current_exception() returns an exception_ptr which refers to an instance of unknown_exception.
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.