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_EXCEPTION.cpp
Go to the documentation of this file.
1
// checking for class std::bad_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
#ifndef _RWSTD_NO_EXCEPTION_SPECIFICATION
35
# define throws(args) throw args
36
#else
37
# define throws(ignore)
38
#endif
// _RWSTD_NO_EXCEPTION_SPECIFICATION
39
40
41
#ifndef _RWSTD_NO_STD_SET_UNEXPECTED
42
43
namespace
std
{
44
45
#endif
// _RWSTD_NO_STD_SET_UNEXPECTED
46
47
48
typedef
void (*
unexpected_handler
)();
49
unexpected_handler
set_unexpected
(
void
(*)())
throws
(());
50
51
52
#ifndef _RWSTD_NO_STD_SET_UNEXPECTED
53
54
}
// std
55
56
# define SET_UNEXPECTED(handler) std::set_unexpected (handler)
57
58
#else
59
60
# define SET_UNEXPECTED(handler) set_unexpected (handler)
61
62
#endif
// _RWSTD_NO_STD_SET_UNEXPECTED
63
64
namespace
std
{
65
66
class
bad_exception
{ };
67
68
}
// namespace std
69
70
71
// will fail if namespace std is not honored
72
enum
bad_exception
{ };
73
74
75
void
foo
()
throws
((
std
::
bad_exception
))
76
{
77
// throw an object of a disallowed type
78
throw
0;
79
}
80
81
void
handler
()
82
{
83
// throw an object of a type not allowed by the exception-specification
84
// of the function that already violated its specification (due to which
85
// the handler has been called); this requires the exception object to be
86
// replaced by the runtime library by one of type [std]::bad_exception
87
throw
""
;
88
}
89
90
int
main
()
91
{
92
SET_UNEXPECTED
(
handler
);
93
94
try
{
95
// will fail if runtime library doesn't recognize std::::bad_exception
96
// by calling terminate()
97
foo
();
98
}
99
catch
(
std::bad_exception
&) {
100
return
0;
101
}
102
catch
(...) {
103
return
1;
104
}
105
106
// runtime library is broken
107
return
2;
108
}
unexpected_handler
void(* unexpected_handler)()
Definition
GLOBAL_SET_UNEXPECTED.cpp:33
handler
void handler()
Definition
STD_BAD_EXCEPTION.cpp:81
throws
#define throws(args)
Definition
STD_BAD_EXCEPTION.cpp:35
SET_UNEXPECTED
#define SET_UNEXPECTED(handler)
Definition
STD_BAD_EXCEPTION.cpp:56
foo
void foo()
Definition
STD_BAD_EXCEPTION.cpp:75
main
int main()
Definition
STD_BAD_EXCEPTION.cpp:90
set_unexpected
int set_unexpected()
bad_exception
Definition
GLOBAL_BAD_EXCEPTION.cpp:65
std::bad_exception
Definition
STD_BAD_EXCEPTION.cpp:66
std
Definition
json.h:5363
terminate.h
Generated by
1.9.8