std::set_terminate
| Defined in header <exception>
|
||
| std::terminate_handler set_terminate( std::terminate_handler f ) throw(); |
(until C++11) | |
| std::terminate_handler set_terminate( std::terminate_handler f ) noexcept; |
(since C++11) | |
Makes f the new global terminate handler function and returns the previously installed std::terminate_handler.
|
This function is thread-safe. Every call to |
(since C++11) |
Contents |
[edit] Parameters
| f | - | pointer to function of type std::terminate_handler, or null pointer |
[edit] Return value
The previously-installed terminate handler, or a null pointer value if none was installed.
[edit] Example
#include <iostream> #include <cstdlib> #include <exception> int main() { std::set_terminate([](){ std::cout << "Unhandled exception\n"; std::abort();}); throw 1; }
Possible output:
Unhandled exception bash: line 7: 7743 Aborted (core dumped) ./a.out
[edit] See also
| function called when exception handling fails (function) | |
| (C++11) |
obtains the current terminate_handler (function) |
| the type of the function called by std::terminate (typedef) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
