Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
STD_BAD_TYPEID.cpp
Go to the documentation of this file.
1// checking for class std::bad_typeid
2
3
25#include "config.h"
26
27#ifndef _RWSTD_NO_TYPEINFO
28# include <typeinfo>
29#else
30# ifndef _RWSTD_NO_TYPEINFO_H
31# include <typeinfo.h>
32# else
33
34// 5.2.8, p6 [expr.typeid]:
35// If the header <typeinfo> is not included prior to a use of typeid,
36// the program is ill-formed.
37namespace std {
38
39class type_info { };
40
41class bad_typeid { };
42
43} // namespace std
44
45# endif // _RWSTD_NO_TYPEINFO_H
46#endif // _RWSTD_NO_TYPEINFO
47
48
49#if 2 == __GNUG__
50# ifndef _RWSTD_NO_HONOR_STD
51# ifdef _RWSTD_NO_STD_TERMINATE
52# include "terminate.h"
53# endif // _RWSTD_NO_STD_TERMINATE
54# endif // _RWSTD_NO_HONOR_STD
55#endif // gcc 2.x
56
57
58// force a failure if namespace std isn't honored
59enum bad_typeid { };
60
61
62struct S { virtual ~S () { } };
63
64int main ()
65{
66 try {
67 S *s = 0;
68
69 // throws [std::] bad_typeid
70 typeid (*s);
71 }
72 catch (std::bad_typeid&) {
73 return 0;
74 }
75 catch (...) {
76 // fail if typeid throws anything other than a std::bad_typeid
77 return 1;
78 }
79
80 // fail if typeid doesn't throw
81 return 2;
82}
#define s
bad_typeid
int main()
Definition json.h:5363
virtual ~S()