• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//  (C) Copyright John Maddock 2008.
2//  Use, modification and distribution are subject to the
3//  Boost Software License, Version 1.0. (See accompanying file
4//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6//  See http://www.boost.org/libs/config for most recent version.
7
8//  MACRO:         BOOST_NO_RTTI
9//  TITLE:         RTTI unavailable
10//  DESCRIPTION:   The compiler does not support RTTI in this mode
11
12#include <typeinfo>
13
14class A
15{
16public:
17   A(){}
18   virtual void t();
19};
20
21void A::t()
22{
23}
24
25class B : public A
26{
27public:
28   B(){}
29   virtual void t();
30};
31
32void B::t()
33{
34}
35
36namespace boost_no_rtti
37{
38
39int check_f(const A& a)
40{
41   return typeid(a) == typeid(B) ? 0 : 1;
42}
43
44int test()
45{
46#if defined( BOOST_NO_EXCEPTIONS )
47   {
48      B b;
49      return check_f(b);
50   }
51#else
52   try{
53      B b;
54      return check_f(b);
55   }
56   catch(...)
57   {
58      return 1;
59   }
60#endif
61}
62
63}
64
65