Date: Mon, 29 May 2023 03:16:16 +0100
Imagine a C++ keyword `try_throw` and a try-throw-statement with the
following syntax:
try-throw-statement:
try_throw assignment-expression_opt ;
If one of the 13 conditions listed in [except.terminate] (
https://eel.is/c++draft/except.terminate) applies, then a
try-throw-statement has no effect (and its expression is not evaluated).
Otherwise, it has the effect of a normal throw expression statement and
control is passed to the appropriate catch handler.
This would mean you could write code like:
if (/* something bad */) {
/* clean up */
try_throw std::runtime_error(/*...*/);
/* attempt to recover locally */
return /* ... */;
}
In essence, it allows for falling back to local recovery when a catch
handler is unavailable. (Normally, in those situations the global
terminate handler is called, and local recovery is not permitted.)
Any thoughts?
following syntax:
try-throw-statement:
try_throw assignment-expression_opt ;
If one of the 13 conditions listed in [except.terminate] (
https://eel.is/c++draft/except.terminate) applies, then a
try-throw-statement has no effect (and its expression is not evaluated).
Otherwise, it has the effect of a normal throw expression statement and
control is passed to the appropriate catch handler.
This would mean you could write code like:
if (/* something bad */) {
/* clean up */
try_throw std::runtime_error(/*...*/);
/* attempt to recover locally */
return /* ... */;
}
In essence, it allows for falling back to local recovery when a catch
handler is unavailable. (Normally, in those situations the global
terminate handler is called, and local recovery is not permitted.)
Any thoughts?
Received on 2023-05-29 02:16:29