• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/exception/current_exception_cast.hpp>
7 #include <boost/detail/lightweight_test.hpp>
8 #include <exception>
9 
10 class
11 my_exception:
12     public std::exception
13     {
14     };
15 
16 class
17 polymorphic
18     {
19     virtual
~polymorphic()20     ~polymorphic()
21         {
22         }
23     };
24 
25 int
main()26 main()
27     {
28     try
29         {
30         throw my_exception();
31         }
32     catch(
33     std::exception & e )
34         {
35         try
36             {
37             throw;
38             }
39         catch(
40         ...)
41             {
42             BOOST_TEST(boost::current_exception_cast<std::exception>()==&e);
43             BOOST_TEST(!boost::current_exception_cast<polymorphic>());
44             }
45         }
46     return boost::report_errors();
47     }
48