Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Establishes a new unexpected_handler to be when an unexpected exception is encountered.
unexpected_handler
set_unexpected(
unexpected_handler fnew
) throw( );
Parameters
- fnew
The function to be called when an unexpected exception is encountered.
Return Value
The address of the previous unexpected_handler.
Remarks
fnew must not be a null pointer.
The C++ Standard requires that unexpected is called when a function throws an exception that is not on its throw list. The current implementation does not support this. The following example calls unexpected directly, which then calls the unexpected_handler.
Example
// 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
}
Output
My unhandled exception function called.
Requirements
Header: <exception>
Namespace: std