#ifndef ACTIV_BOOST_THROW_EXCEPTION_HPP_INCLUDED #define ACTIV_BOOST_THROW_EXCEPTION_HPP_INCLUDED // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif // // ActivBoost/throw_exception.hpp // // Copyright (c) 2002, 2018, 2019 Peter Dimov // Copyright (c) 2008-2009 Emil Dotchevski and Reverge Studios, Inc. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // http://www.boost.org/libs/throw_exception // #include #include #include #include #include #include #if !defined( ACTIV_BOOST_EXCEPTION_DISABLE ) && defined( ACTIV_BOOST_BORLANDC ) && ACTIV_BOOST_WORKAROUND( ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x593) ) # define ACTIV_BOOST_EXCEPTION_DISABLE #endif namespace Boost { #if defined( ACTIV_BOOST_NO_EXCEPTIONS ) ACTIV_BOOST_NORETURN void throw_exception( std::exception const & e ); // user defined ACTIV_BOOST_NORETURN void throw_exception( std::exception const & e, Boost::source_location const & loc ); // user defined #endif // Boost::wrapexcept namespace detail { typedef char (&wrapexcept_s1)[ 1 ]; typedef char (&wrapexcept_s2)[ 2 ]; template wrapexcept_s1 wrapexcept_is_convertible( T* ); template wrapexcept_s2 wrapexcept_is_convertible( void* ); template( static_cast< E* >( 0 ) ) ) > struct wrapexcept_add_base; template struct wrapexcept_add_base { struct type {}; }; template struct wrapexcept_add_base { typedef B type; }; } // namespace detail template struct ACTIV_BOOST_SYMBOL_VISIBLE wrapexcept: public detail::wrapexcept_add_base::type, public E, public detail::wrapexcept_add_base::type { private: struct deleter { wrapexcept * p_; ~deleter() { delete p_; } }; private: void copy_from( void const* ) { } void copy_from( Boost::exception const* p ) { static_cast( *this ) = *p; } public: explicit wrapexcept( E const & e ): E( e ) { copy_from( &e ); } explicit wrapexcept( E const & e, Boost::source_location const & loc ): E( e ) { copy_from( &e ); set_info( *this, throw_file( loc.file_name() ) ); set_info( *this, throw_line( loc.line() ) ); set_info( *this, throw_function( loc.function_name() ) ); } virtual Boost::exception_detail::clone_base const * clone() const ACTIV_BOOST_OVERRIDE { wrapexcept * p = new wrapexcept( *this ); deleter del = { p }; Boost::exception_detail::copy_boost_exception( p, this ); del.p_ = 0; return p; } virtual void rethrow() const ACTIV_BOOST_OVERRIDE { #if defined( ACTIV_BOOST_NO_EXCEPTIONS ) Boost::throw_exception( *this ); #else throw *this; #endif } }; // All boost exceptions are required to derive from std::exception, // to ensure compatibility with ACTIV_BOOST_NO_EXCEPTIONS. inline void throw_exception_assert_compatibility( std::exception const & ) {} // Boost::throw_exception #if !defined( ACTIV_BOOST_NO_EXCEPTIONS ) #if defined( ACTIV_BOOST_EXCEPTION_DISABLE ) template ACTIV_BOOST_NORETURN void throw_exception( E const & e ) { throw_exception_assert_compatibility( e ); throw e; } template ACTIV_BOOST_NORETURN void throw_exception( E const & e, Boost::source_location const & ) { throw_exception_assert_compatibility( e ); throw e; } #else // defined( ACTIV_BOOST_EXCEPTION_DISABLE ) template ACTIV_BOOST_NORETURN void throw_exception( E const & e ) { throw_exception_assert_compatibility( e ); throw wrapexcept( e ); } template ACTIV_BOOST_NORETURN void throw_exception( E const & e, Boost::source_location const & loc ) { throw_exception_assert_compatibility( e ); throw wrapexcept( e, loc ); } #endif // defined( ACTIV_BOOST_EXCEPTION_DISABLE ) #endif // !defined( ACTIV_BOOST_NO_EXCEPTIONS ) } // namespace Boost // ACTIV_BOOST_THROW_EXCEPTION #define ACTIV_BOOST_THROW_EXCEPTION(x) ::Boost::throw_exception(x, ACTIV_BOOST_CURRENT_LOCATION) #endif // #ifndef ACTIV_BOOST_THROW_EXCEPTION_HPP_INCLUDED