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