|
|
Defined in header <exception> | ||
typedefvoid(*unexpected_handler)(); | (deprecated in C++11) (removed in C++17) | |
std::unexpected_handler
is the function pointer type (pointer to function that takes no arguments and returns void), which is installed and queried by the functionsstd::set_unexpected andstd::get_unexpected and called bystd::unexpected.
The C++ implementation provides a defaultstd::unexpected_handler
function, which callsstd::terminate(). If the null pointer value is installed (by means ofstd::set_unexpected), the implementation may restore the default handler instead.
A user-definedstd::unexpected_handler
is expected to either terminate the program or throw an exception. If it throws an exception, one of the following three situations may be encountered:
1) the exception thrown bystd::unexpected_handler
satisfies the dynamic exception specification that was violated earlier. The new exception is allowed to escape the function and stack unwinding continues.
2) the exception thrown bystd::unexpected_handler
still violates the exception specification:
2a) however, the exception specification allowsstd::bad_exception: the thrown exception object is destroyed, andstd::bad_exception is constructed by the C++ runtime and thrown instead.
2b) the exception specification does not allowstd::bad_exception:std::terminate() is called.
(deprecated in C++11)(removed in C++17) | function called when dynamic exception specification is violated (function)[edit] |
(deprecated in C++11)(removed in C++17) | changes the function to be called bystd::unexpected (function)[edit] |
(deprecated in C++11)(removed in C++17) | obtains the currentunexpected_handler (function)[edit] |