1 // Copyright 2020 Peter Dimov 2 // Distributed under the Boost Software License, Version 1.0. 3 // http://www.boost.org/LICENSE_1_0.txt 4 5 #if defined(_MSC_VER) 6 # pragma warning(disable: 4702) // unreachable code 7 # pragma warning(disable: 4577) // noexcept used without /EHsc 8 #endif 9 10 //#include <boost/exception_ptr.hpp> 11 12 #include <boost/throw_exception.hpp> 13 #include <boost/exception/exception.hpp> 14 #include <boost/shared_ptr.hpp> 15 #include <boost/make_shared.hpp> 16 17 typedef boost::shared_ptr<boost::exception_detail::clone_base const> exception_ptr; 18 make_exception_ptr(E const & e)19template<class E> exception_ptr make_exception_ptr( E const& e ) 20 { 21 return boost::make_shared< boost::wrapexcept<E> >( e ); 22 } 23 24 class my_exception: public std::exception {}; 25 main()26int main() 27 { 28 ::make_exception_ptr( my_exception() ); 29 } 30 31 namespace boost 32 { 33 34 // shared_ptr needs this throw_exception(std::exception const &)35void throw_exception( std::exception const & ) 36 { 37 std::exit( 1 ); 38 } 39 40 } // namespace boost 41