set_unexpected (<exception>)
予期しない例外が発生したときに新しい unexpected_handler が存在するように設定します。
unexpected_handler
set_unexpected(
unexpected_handler fnew
) throw( );
パラメーター
- fnew
予期しない例外が発生したときに呼び出される関数。
戻り値
以前の unexpected_handler のアドレス。
解説
fnew を null ポインターにすることはできません。
C++ 標準では、関数が throw のリストにない例外をスローした場合に、unexpected を呼び出す必要があります。 現在の実装では、これをサポートしていません。 次の例では、unexpected を直接呼び出し、その後で unexpected_handler を呼び出します。
使用例
// exception_set_unexpected.cpp
// compile with: /EHsc
#include <exception>
#include <iostream>
using namespace std;
void uefunction()
{
cout << "My unhandled exception function called." << endl;
terminate(); // this is what unexpected() calls by default
}
int main()
{
unexpected_handler oldHandler = set_unexpected(uefunction);
unexpected(); // library function to force calling the
// current unexpected handler
}
出力
My unhandled exception function called.
必要条件
ヘッダー: <例外>
名前空間: std