function
<exception>
std::set_terminateterminate_handler set_terminate (terminate_handler f) throw();
terminate_handler set_terminate (terminate_handler f) noexcept;
Set terminate handler function
Sets f as the terminate handler function.A terminate handler function is a function automatically called when the exception handling process has to be abandoned for some reason. This happens when no catch
handler can be found for a thrown exception, or for some other exceptional circumstance that makes impossible to continue the exception handling process.
Before this function is called by the program for the first time, the default behavior is to call abort.
A program may explicitly call the current terminate handler function by calling terminate,
void
).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// set_terminate example
#include <iostream> // std::cerr
#include <exception> // std::set_terminate
#include <cstdlib> // std::abort
void myterminate () {
std::cerr << "terminate handler called\n";
abort(); // forces abnormal termination
}
int main (void) {
std::set_terminate (myterminate);
throw 0; // unhandled exception: calls terminate handler
return 0;
}
terminate handler called Aborted
Notice that this requirement applies only to the set_terminate function, but not necessarily to the terminate handler function passed as argument (f).
Notice that if f is a function that does not implement the proper functionality (described above), or if f is an invalid or null pointer, it causes undefined behavior.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4