ON_THROW#

ON_THROW(...)#

Statement-shaped on_throw: ON_THROW(policy-expression) { body }; The policy expression is evaluated with exception_policies visible, so ON_THROW(notify & retry * 3 | subst(-1)) { return flaky(); }; needs no qualification.

All arguments forward to on_throw, so a source_location may follow the policy: ON_THROW(notify, loc) { body };. Expands to on_throw(…) << a reference-capturing lambda; the call-site location is captured exactly as with plain on_throw. The macro ends at [&](): supply the body type by composition when needed, as in ON_THROW(retry | subst(-1)) -> int { throw failure(); };.

The block-scope using-declarations pin abort and terminate to the policies. Without them, using the macro at global scope with the C library in scope would be ambiguous: the using-directive parks the policy names at the nearest namespace enclosing both it and exception_policies, which in user code is the global namespace, right next to the C library’s abort.