tmp/tmpilc85pho/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Throwing an exception <a id="expr.throw">[[expr.throw]]</a>
|
| 2 |
+
|
| 3 |
+
``` bnf
|
| 4 |
+
throw-expression:
|
| 5 |
+
'throw' assignment-expressionₒₚₜ
|
| 6 |
+
```
|
| 7 |
+
|
| 8 |
+
A *throw-expression* is of type `void`.
|
| 9 |
+
|
| 10 |
+
Evaluating a *throw-expression* with an operand throws an exception (
|
| 11 |
+
[[except.throw]]); the type of the exception object is determined by
|
| 12 |
+
removing any top-level *cv-qualifier*s from the static type of the
|
| 13 |
+
operand and adjusting the type from “array of `T`” or function type `T`
|
| 14 |
+
to “pointer to `T`”.
|
| 15 |
+
|
| 16 |
+
A *throw-expression* with no operand rethrows the currently handled
|
| 17 |
+
exception ([[except.handle]]). The exception is reactivated with the
|
| 18 |
+
existing exception object; no new exception object is created. The
|
| 19 |
+
exception is no longer considered to be caught.
|
| 20 |
+
|
| 21 |
+
[*Example 1*:
|
| 22 |
+
|
| 23 |
+
Code that must be executed because of an exception, but cannot
|
| 24 |
+
completely handle the exception itself, can be written like this:
|
| 25 |
+
|
| 26 |
+
``` cpp
|
| 27 |
+
try {
|
| 28 |
+
// ...
|
| 29 |
+
} catch (...) { // catch all exceptions
|
| 30 |
+
// respond (partially) to exception
|
| 31 |
+
throw; // pass the exception to some other handler
|
| 32 |
+
}
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
— *end example*]
|
| 36 |
+
|
| 37 |
+
If no exception is presently being handled, evaluating a
|
| 38 |
+
*throw-expression* with no operand calls `std::{}terminate()` (
|
| 39 |
+
[[except.terminate]]).
|
| 40 |
+
|