From 56dd1c41115ab81e09fa46c3977d039fdea49cc6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Sep 2018 07:39:18 +0300 Subject: [PATCH 1/2] Add/use exception_detail::enable_both --- include/boost/exception/exception.hpp | 12 ++++++++++++ include/boost/throw_exception.hpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index be70b3c..1460473 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -472,6 +472,18 @@ boost { return exception_detail::clone_impl(x); } + + namespace + exception_detail + { + template + inline + clone_impl::type> + enable_both( T const & x ) + { + return enable_current_exception( enable_error_info( x ) ); + } + } } #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index a96dded..c6623e1 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -67,7 +67,7 @@ template BOOST_NORETURN inline void throw_exception( E const & e ) throw_exception_assert_compatibility(e); #ifndef BOOST_EXCEPTION_DISABLE - throw enable_current_exception(enable_error_info(e)); + throw exception_detail::enable_both( e ); #else throw e; #endif From 322d7611af7d745e2ab358b589c0904a28575635 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Sep 2018 08:13:59 +0300 Subject: [PATCH 2/2] Use boost::wrapexcept as the thrown exception type --- include/boost/exception/exception.hpp | 37 +++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 1460473..d5c22c4 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -473,15 +473,48 @@ boost return exception_detail::clone_impl(x); } + template + struct + BOOST_SYMBOL_VISIBLE + wrapexcept: + public exception_detail::clone_impl::type> + { + typedef exception_detail::clone_impl::type> base_type; + public: + explicit + wrapexcept( typename exception_detail::enable_error_info_return_type::type const & x ): + base_type( x ) + { + } + + ~wrapexcept() throw() + { + } + }; + namespace exception_detail { + template + struct + remove_error_info_injector + { + typedef T type; + }; + + template + struct + remove_error_info_injector< error_info_injector > + { + typedef T type; + }; + template inline - clone_impl::type> + wrapexcept::type> enable_both( T const & x ) { - return enable_current_exception( enable_error_info( x ) ); + return wrapexcept::type>( enable_error_info( x ) ); } } }