Define boost::wrapexcept when BOOST_NO_EXCEPTIONS is defined, to enable boost::make_exception_ptr

This commit is contained in:
Peter Dimov
2020-12-20 02:03:11 +02:00
parent 397bc3d675
commit f3b43b5679
5 changed files with 126 additions and 33 deletions

View File

@ -20,6 +20,7 @@
// http://www.boost.org/libs/throw_exception
//
#include <boost/exception/exception.hpp>
#include <boost/assert/source_location.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
@ -32,29 +33,12 @@
namespace boost
{
// All boost exceptions are required to derive from std::exception,
// to ensure compatibility with BOOST_NO_EXCEPTIONS.
inline void throw_exception_assert_compatibility( std::exception const & ) {}
} // namespace boost
#if defined( BOOST_NO_EXCEPTIONS )
namespace boost
{
BOOST_NORETURN void throw_exception( std::exception const & e ); // user defined
BOOST_NORETURN void throw_exception( std::exception const & e, boost::source_location const & loc ); // user defined
} // namespace boost
#else // !defined( BOOST_NO_EXCEPTIONS )
#include <boost/exception/exception.hpp>
namespace boost
{
#endif
// boost::wrapexcept<E>
@ -134,17 +118,29 @@ public:
virtual void rethrow() const BOOST_OVERRIDE
{
#if defined( BOOST_NO_EXCEPTIONS )
boost::throw_exception( *this );
#else
throw *this;
#endif
}
};
} // namespace boost
// All boost exceptions are required to derive from std::exception,
// to ensure compatibility with BOOST_NO_EXCEPTIONS.
inline void throw_exception_assert_compatibility( std::exception const & ) {}
// boost::throw_exception
#if !defined( BOOST_NO_EXCEPTIONS )
#if defined( BOOST_EXCEPTION_DISABLE )
namespace boost
{
template<class E> BOOST_NORETURN void throw_exception( E const & e )
{
throw_exception_assert_compatibility( e );
@ -157,13 +153,7 @@ template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::sourc
throw e;
}
} // namespace boost
#else // !defined( BOOST_EXCEPTION_DISABLE )
namespace boost
{
// boost::throw_exception
#else // defined( BOOST_EXCEPTION_DISABLE )
template<class E> BOOST_NORETURN void throw_exception( E const & e )
{
@ -177,12 +167,12 @@ template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::sourc
throw wrapexcept<E>( e, loc );
}
#endif // defined( BOOST_EXCEPTION_DISABLE )
#endif // !defined( BOOST_NO_EXCEPTIONS )
} // namespace boost
#endif // # if defined( BOOST_EXCEPTION_DISABLE )
#endif // # if defined( BOOST_NO_EXCEPTIONS )
// BOOST_THROW_EXCEPTION
#define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x, BOOST_CURRENT_LOCATION)