std_exception_ptr_wrapper

This commit is contained in:
Emil Dotchevski
2020-01-29 14:02:40 -08:00
parent af98afb3d1
commit 3f6ff1a8bf

View File

@ -299,6 +299,14 @@ boost
return boost::copy_exception(unknown_exception(e)); return boost::copy_exception(unknown_exception(e));
} }
#ifndef BOOST_NO_CXX11_HDR_EXCEPTION
struct
std_exception_ptr_wrapper
{
std::exception_ptr p;
};
#endif
inline inline
exception_ptr exception_ptr
current_exception_impl() current_exception_impl()
@ -432,8 +440,8 @@ boost
try try
{ {
// wrap the std::exception_ptr in a clone-enabled Boost.Exception object // wrap the std::exception_ptr in a clone-enabled Boost.Exception object
exception_detail::clone_base const& base = exception_detail::clone_base const & base =
boost::enable_current_exception(std::current_exception()); boost::enable_current_exception(std_exception_ptr_wrapper{std::current_exception()});
return exception_ptr(shared_ptr<exception_detail::clone_base const>(base.clone())); return exception_ptr(shared_ptr<exception_detail::clone_base const>(base.clone()));
} }
catch( catch(
@ -485,10 +493,10 @@ boost
p.ptr_->rethrow(); p.ptr_->rethrow();
} }
catch( catch(
const std::exception_ptr& std_ep) exception_detail::std_exception_ptr_wrapper const & wrp)
{ {
// if an std::exception_ptr was wrapped above then rethrow it // if an std::exception_ptr was wrapped above then rethrow it
std::rethrow_exception(std_ep); std::rethrow_exception(wrp.p);
} }
#else #else
p.ptr_->rethrow(); p.ptr_->rethrow();