1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. 2 3 //Distributed under the Boost Software License, Version 1.0. (See accompanying 4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #include <boost/config.hpp> 7 8 #if defined( BOOST_NO_EXCEPTIONS ) 9 # error This program requires exception handling. 10 #endif 11 12 #include <boost/exception/current_exception_cast.hpp> 13 #include <boost/detail/lightweight_test.hpp> 14 #include <exception> 15 16 class 17 my_exception: 18 public std::exception 19 { 20 }; 21 22 class 23 polymorphic 24 { 25 virtual ~polymorphic()26 ~polymorphic() 27 { 28 } 29 }; 30 31 int main()32main() 33 { 34 try 35 { 36 throw my_exception(); 37 } 38 catch( 39 std::exception & e ) 40 { 41 try 42 { 43 throw; 44 } 45 catch( 46 ...) 47 { 48 BOOST_TEST(boost::current_exception_cast<std::exception>()==&e); 49 BOOST_TEST(!boost::current_exception_cast<polymorphic>()); 50 } 51 } 52 return boost::report_errors(); 53 } 54