Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
STD_EXCEPTION.cpp
Go to the documentation of this file.
1// checking for class std::exception
2
3
25#include "config.h"
26
27#ifndef _RWSTD_NO_HONOR_STD
28# ifdef _RWSTD_NO_STD_TERMINATE
29# include "terminate.h"
30# endif // _RWSTD_NO_STD_TERMINATE
31#endif // _RWSTD_NO_HONOR_STD
32
33
34// will fail if namespaces aren't supported
35namespace std {
36
37class exception { };
38
39}
40
41// force a failure if namespace std isn't honored
42class exception { };
43
44
45struct B { virtual ~B () { } };
46struct D1: B { };
47struct D2: B { };
48
49int main ()
50{
51 D1 d1;
52 B &b = d1;
53
54 try {
55 // throws [std::] bad_cast
56 D2 &d2 = dynamic_cast<D2&>(b);
57 }
58 catch (exception&) {
59 // fail if namespace std isn't honored
60 return 1;
61 }
62 catch (std::exception&) {
63 return 0;
64 }
65 catch (...) {
66 // fail if cast throws anything other than an std::exception-derivative
67 return 1;
68 }
69
70 // fail if cast doesn't throw
71 return 2;
72}
#define d1
Definition 17.names.cpp:228
#define b
Definition 17.names.cpp:110
#define d2
Definition 17.names.cpp:254
int main()
Definition json.h:5363
virtual ~B()