首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::terminate

Defined in header <exception>

?

?

void terminate();

?

(until C++11)

[noreturn] void terminate();

?

(since C++11)

std::terminate()当异常处理因下列任何原因而失败时,C++运行时调用:

1%29 a异常抛出。未捕获%28,则实现定义是否完成堆栈展开(在本例中为%29)。

2%29在异常处理%28 e.g期间引发异常。来自某个本地对象的析构函数,或者来自在异常处理%29期间必须调用的函数。

3%29静态或线程本地对象的构造函数或析构函数引发异常。

4%29std::atexitstd::at_quick_exit抛出异常

5%29 a除规格外它是实现定义的,在本例中是否完成堆栈展开--在本例中为%29。

6) a dynamic exception specification is violated and the default handler for std::unexpected is executed 7) a non-default handler for std::unexpected throws an exception that violates the previously violated dynamic exception specification, if the specification does not include std::bad_exception

(until C++17)

8%29std::nested_exception::rethrow_nested为保存捕获异常的%27T对象调用

9%29从std::thread

10%29 a可接合std::thread被销毁或分配给

11) a function invoked by a parallel algorithm exits via an uncaught exception and the execution policy specifies termination.

(since C++17)

std::terminate()也可以直接从程序调用。

无论如何std::terminate调用当前安装的std::terminate_handler.默认std::terminate_handler打电话std::abort...

If a destructor reset the terminate handler during stack unwinding and the unwinding later led to terminate being called, the handler that was installed at the end of the throw expression is the one that will be called. (note: it was ambiguous whether re-throwing applied the new handlers).

(until C++11)

If a destructor reset the terminate handler during stack unwinding, it is unspecified which handler is called if the unwinding later led to terminate being called.

(since C++17)

参数

%280%29

返回值

%280%29

例外

(none)

(until C++11)

noexcept specification: noexcept

(since C++11)

另见

terminate_handler

the type of the function called by std::terminate (typedef)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com