std::set_terminate
提供: cppreference.com
ヘッダ <exception> で定義 | ||
std::terminate_handler set_terminate(std::terminate_handler f )throw(); | (C++11未満) | |
std::terminate_handler set_terminate(std::terminate_handler f )noexcept; | (C++11以上) | |
f
を新しいグローバルな終了ハンドラに設定し、以前設定されていた std::terminate_handler を返します。
この関数はスレッドセーフです。 | (C++11以上) |
目次 |
[編集]引数
f | - | std::terminate_handler 型の関数へのポインタ、またはヌルポインタ |
[編集]戻り値
以前設定した終了ハンドラ、または何も設定されていなければヌルポインタ値。
[編集]例
Run this code
#include <iostream>#include <cstdlib>#include <exception> int main(){ std::set_terminate([](){std::cout<<"Unhandled exception\n";std::abort();});throw1;}
出力例:
Unhandled exception bash: line 7: 7743 Aborted (core dumped) ./a.out
[編集]関連項目
例外処理が失敗したときに呼ばれる関数 (関数) | |
(C++11) | 現在の terminate_handler を取得します (関数) |
std::terminate によって呼ばれる関数の型 (typedef) |