Name

terminate function — Terminates program when exception handling fails

Synopsis

void terminate(  )

The terminate function is called when normal exception handling cannot handle an exception for any reason—for example, when there is no matching catch block for an exception, or when an exception is thrown and, while the stack is unwinding, another exception is thrown by a destructor.

A program might also call terminate explicitly.

You can change the behavior of the terminate function by calling set_terminate. The default behavior is to call abort.

The terminate function is a last resort because normal exception handling failed. For this reason, you cannot rely on the usual destruction of static objects and objects on the stack.

See Also

set_terminate function, unexpected function, abort function in <cstdlib> , catch keyword

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.