17 Language support library [support]

17.9 Exception handling [support.exception]

17.9.5 Abnormal termination [exception.terminate]

17.9.5.1 Type terminate_­handler [terminate.handler]

using terminate_handler = void (*)();
The type of a handler function to be invoked by terminate when terminating exception processing.
Required behavior: A terminate_­handler shall terminate execution of the program without returning to the caller.
Default behavior: The implementation's default terminate_­handler calls abort().

17.9.5.2 set_­terminate [set.terminate]

terminate_handler set_terminate(terminate_handler f) noexcept;
Effects: Establishes the function designated by f as the current handler function for terminating exception processing.
Returns: The previous terminate_­handler.
Remarks: It is unspecified whether a null pointer value designates the default terminate_­handler.

17.9.5.3 get_­terminate [get.terminate]

terminate_handler get_terminate() noexcept;
Returns: The current terminate_­handler.
[Note 1:
This can be a null pointer value.
— end note]

17.9.5.4 terminate [terminate]

[[noreturn]] void terminate() noexcept;
Effects: Calls a terminate_­handler function.
It is unspecified which terminate_­handler function will be called if an exception is active during a call to set_­terminate.
Otherwise calls the current terminate_­handler function.
[Note 1:
A default terminate_­handler is always considered a callable handler in this context.
— end note]
Remarks: Called by the implementation when exception handling must be abandoned for any of several reasons ([except.terminate]).
May also be called directly by the program.