- exception[meta header]
- std[meta namespace]
- function[meta id-type]
namespace std {
using terminate_handler = void(*)();
terminate_handler set_terminate(terminate_handler f) noexcept;
}
例外をキャッチされなかった場合に実行される終了ハンドラを設定する。
前に設定されていた終了ハンドラを返す。
投げない
引数としてヌルポインタが渡された場合、デフォルトの終了ハンドラが設定される。
終了ハンドラは、呼び出し元に戻らずに異常終了すべきと規定されている。
#include <iostream>
#include <exception>
void my_terminate_handler()
{
std::cout << "my terminate handler" << std::endl;
}
int main()
{
std::set_terminate(my_terminate_handler);
throw std::exception(); // no catch
}
- std::set_terminate[color ff0000]
- std::exception[link exception.md]
my terminate handler
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.