What is a good use case for uncaught_exception?
Return type of uncaught_exception() is bool.
std::terminate() is called by the C++ runtime when the program cannot continue for any of the following reasons: 1) an exception is thrown and not caught (it is implementation-defined whether any stack unwinding is done in this case)
The terminate( ) function If no handler at any level catches the exception, the special library function terminate( ) (declared in the <exception> header) is automatically called. By default, terminate( ) calls the Standard C library function abort( ) , which abruptly exits the program.
A C++ exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another. C++ exception handling is built upon three keywords: try, catch, and throw.
Herb Sutter seems to give good advice here. He doesn't know of a good use for it and says that some cases where it appears to be useful don't really work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With