Index: boost/exception/exception.hpp =================================================================== --- boost/exception/exception.hpp (revision 59837) +++ boost/exception/exception.hpp (working copy) @@ -401,6 +401,14 @@ copy_boost_exception(this,&x); } + template + clone_impl( T const & x, VirtualBase & vb ): + VirtualBase(vb), + T(x) + { + copy_boost_exception(this,&x); + } + ~clone_impl() throw() { } @@ -428,6 +436,14 @@ { return exception_detail::clone_impl(x); } + + template + inline + exception_detail::clone_impl + enable_current_exception( T const & x, VirtualBase const & vb ) + { + return exception_detail::clone_impl(x,vb); + } } #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) Index: boost/throw_exception.hpp =================================================================== --- boost/throw_exception.hpp (revision 59836) +++ boost/throw_exception.hpp (working copy) @@ -67,6 +67,11 @@ void throw_exception( std::exception const & e ); // user defined +template BOOST_ATTRIBUTE_NORETURN inline void throw_exception( E const & e, VirtualBase const & ) +{ + return throw_exception(e); +} + #else inline void throw_exception_assert_compatibility( std::exception const & ) { } @@ -84,8 +89,21 @@ #endif } +template BOOST_ATTRIBUTE_NORETURN inline void throw_exception( E const & e, VirtualBase const & vb ) +{ + //All boost exceptions are required to derive from std::exception, + //to ensure compatibility with BOOST_NO_EXCEPTIONS. + throw_exception_assert_compatibility(e); + +#ifndef BOOST_EXCEPTION_DISABLE + throw enable_current_exception(enable_error_info(e),vb); +#else + throw e; #endif +} +#endif + } // namespace boost #endif // #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED Index: libs/exception/test/Jamfile.v2 =================================================================== --- libs/exception/test/Jamfile.v2 (revision 59836) +++ libs/exception/test/Jamfile.v2 (working copy) @@ -37,6 +37,7 @@ run no_exceptions_test.cpp : : : off ; run errinfos_test.cpp ; run exception_ptr_test.cpp /boost//thread : : : multi ; +run virtual_base_test.cpp ; compile-fail exception_fail.cpp ; compile-fail throw_exception_fail.cpp ; compile-fail error_info_const_fail.cpp ; Index: libs/exception/test/virtual_base_test.cpp =================================================================== --- libs/exception/test/virtual_base_test.cpp (revision 0) +++ libs/exception/test/virtual_base_test.cpp (revision 0) @@ -0,0 +1,34 @@ +//Copyright (c) 2006-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) + +#include +#include +#include + +struct +err: + virtual boost::exception, + virtual std::runtime_error + { + err(): + std::runtime_error("what") + { + } + }; + +int +main() + { + try + { + boost::throw_exception(err(),std::runtime_error("what")); + } + catch( + err & e ) + { + BOOST_TEST(dynamic_cast(&e)!=0); + } + return boost::report_errors(); + }