std::unexpected_handler
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <exception> 中定义
|
||
typedef void (*unexpected_handler)(); |
(已弃用) | |
std::unexpected_handler
的函数指针类型(指针到函数不带任何参数,并返回void),这是安装和查询的功能std::set_unexpected和std::get_unexpected,并呼吁通过std::unexpected.原文:
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 functions std::set_unexpected and std::get_unexpected and called by std::unexpected.C + +的实现提供了一个默认
std::unexpected_handler
功能,这就要求std::terminate()。如果空指针的值是安装(手段std::set_terminate),实现可能会恢复默认的处理程序,而不是.原文:
The C++ implementation provides a default
std::unexpected_handler
function, which calls std::terminate(). If the null pointer value is installed (by means of std::set_terminate), the implementation may restore the default handler instead.用户定义的
1) std::unexpected_handler
预计终止程序,或者抛出一个异常。如果它抛出一个异常,可能会遇到以下三种情况之一的:原文:
A user-defined
std::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:std::unexpected_handler
满足动态例外,规范,违反了新的例外是允许逃跑的功能和堆栈平仓继续原文:
the exception thrown by
std::unexpected_handler
satisfies the dynamic exception specification that was violated earlier. The new exception is allowed to escape the function and stack unwinding continues.抛出的异常的
std::unexpected_handler
仍然违反的异常规范原文:
the exception thrown by
std::unexpected_handler
still violates the exception specification:2A),但是,异常规范允许std::bad_exception:抛出的异常对象被销毁,std::bad_exception是通过C + +运行时抛出,而不是.
原文:
2a) however, the exception specification allows std::bad_exception: the thrown exception object is destroyed, and std::bad_exception is constructed by the C++ runtime and thrown instead.
2B)的例外规范不允许std::bad_exception:std::terminate()被称为.
原文:
2b) the exception specification does not allow std::bad_exception: std::terminate() is called.
[编辑] 另请参阅
(已弃用) |
函数调用动态的异常规范被违反时 原文: function called when dynamic exception specification is violated (函数) |
(已弃用) |
改变功能被称为由std::unexpected 原文: changes the function to be called by std::unexpected (函数) |
(C++11)(已弃用) |
获得电流unexpected_handler 原文: obtains the current unexpected_handler (函数) |