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