Files
cppdraft_translate/cppdraft/expr/throw.md
2025-10-25 03:02:53 +03:00

2.6 KiB
Raw Blame History

[expr.throw]

7 Expressions [expr]

7.6 Compound expressions [expr.compound]

7.6.18 Throwing an exception [expr.throw]

throw-expression:
throw assignment-expressionopt

1

#

A throw-expression is of type void.

2

#

A throw-expression with an operand throws an exception ([except.throw]).

The array-to-pointer ([conv.array]) and function-to-pointer ([conv.func]) standard conversions are performed on the operand.

The type of the exception object is determined by removing any top-level cv-qualifiers from the type of the (possibly converted) operand.

The exception object is copy-initialized ([dcl.init.general]) from the (possibly converted) operand.

3

#

Athrow-expression with no operand rethrows the currently handled exception ([except.handle]).

If no exception is presently being handled, the function std::terminate is invoked ([except.terminate]).

Otherwise, the exception is reactivated with the existing exception object; no new exception object is created.

The exception is no longer considered to be caught.

[Example 1:

An exception handler that cannot completely handle the exception itself can be written like this:try {// ...} catch (...) { // catch all exceptions// respond (partially) to exceptionthrow; // pass the exception to some other handler}

— end example]