tmp/tmp13pyga_n/{from.md → to.md}
RENAMED
|
@@ -4,26 +4,30 @@ Jump statements unconditionally transfer control.
|
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
jump-statement:
|
| 7 |
'break ;'
|
| 8 |
'continue ;'
|
| 9 |
-
'return'
|
| 10 |
-
'return' braced-init-list ';'
|
| 11 |
'goto' identifier ';'
|
| 12 |
```
|
| 13 |
|
| 14 |
On exit from a scope (however accomplished), objects with automatic
|
| 15 |
storage duration ([[basic.stc.auto]]) that have been constructed in
|
| 16 |
-
that scope are destroyed in the reverse order of their construction.
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
### The `break` statement <a id="stmt.break">[[stmt.break]]</a>
|
| 27 |
|
| 28 |
The `break` statement shall occur only in an *iteration-statement* or a
|
| 29 |
`switch` statement and causes termination of the smallest enclosing
|
|
@@ -69,38 +73,48 @@ equivalent to `goto` `contin`.
|
|
| 69 |
|
| 70 |
### The `return` statement <a id="stmt.return">[[stmt.return]]</a>
|
| 71 |
|
| 72 |
A function returns to its caller by the `return` statement.
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
function
|
| 77 |
[[class.ctor]]), or a destructor ([[class.dtor]]). A return statement
|
| 78 |
-
with an
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
[[
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
``` cpp
|
| 91 |
std::pair<std::string,int> f(const char* p, int x) {
|
| 92 |
return {p,x};
|
| 93 |
}
|
| 94 |
```
|
| 95 |
|
| 96 |
-
|
| 97 |
-
value; this results in undefined behavior in a value-returning function.
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
### The `goto` statement <a id="stmt.goto">[[stmt.goto]]</a>
|
| 104 |
|
| 105 |
The `goto` statement unconditionally transfers control to the statement
|
| 106 |
labeled by the identifier. The identifier shall be a label (
|
|
|
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
jump-statement:
|
| 7 |
'break ;'
|
| 8 |
'continue ;'
|
| 9 |
+
'return' expr-or-braced-init-listₒₚₜ ';'
|
|
|
|
| 10 |
'goto' identifier ';'
|
| 11 |
```
|
| 12 |
|
| 13 |
On exit from a scope (however accomplished), objects with automatic
|
| 14 |
storage duration ([[basic.stc.auto]]) that have been constructed in
|
| 15 |
+
that scope are destroyed in the reverse order of their construction.
|
| 16 |
+
|
| 17 |
+
[*Note 1*: For temporaries, see [[class.temporary]]. — *end note*]
|
| 18 |
+
|
| 19 |
+
Transfer out of a loop, out of a block, or back past an initialized
|
| 20 |
+
variable with automatic storage duration involves the destruction of
|
| 21 |
+
objects with automatic storage duration that are in scope at the point
|
| 22 |
+
transferred from but not at the point transferred to. (See [[stmt.dcl]]
|
| 23 |
+
for transfers into blocks).
|
| 24 |
+
|
| 25 |
+
[*Note 2*: However, the program can be terminated (by calling
|
| 26 |
+
`std::exit()` or `std::abort()` ([[support.start.term]]), for example)
|
| 27 |
+
without destroying class objects with automatic storage
|
| 28 |
+
duration. — *end note*]
|
| 29 |
|
| 30 |
### The `break` statement <a id="stmt.break">[[stmt.break]]</a>
|
| 31 |
|
| 32 |
The `break` statement shall occur only in an *iteration-statement* or a
|
| 33 |
`switch` statement and causes termination of the smallest enclosing
|
|
|
|
| 73 |
|
| 74 |
### The `return` statement <a id="stmt.return">[[stmt.return]]</a>
|
| 75 |
|
| 76 |
A function returns to its caller by the `return` statement.
|
| 77 |
|
| 78 |
+
The *expr-or-braced-init-list* of a return statement is called its
|
| 79 |
+
operand. A return statement with no operand shall be used only in a
|
| 80 |
+
function whose return type is cv `void`, a constructor (
|
| 81 |
[[class.ctor]]), or a destructor ([[class.dtor]]). A return statement
|
| 82 |
+
with an operand of type `void` shall be used only in a function whose
|
| 83 |
+
return type is cv `void`. A return statement with any other operand
|
| 84 |
+
shall be used only in a function whose return type is not cv `void`; the
|
| 85 |
+
return statement initializes the glvalue result or prvalue result object
|
| 86 |
+
of the (explicit or implicit) function call by copy-initialization (
|
| 87 |
+
[[dcl.init]]) from the operand.
|
| 88 |
+
|
| 89 |
+
[*Note 1*: A return statement can involve an invocation of a
|
| 90 |
+
constructor to perform a copy or move of the operand if it is not a
|
| 91 |
+
prvalue or if its type differs from the return type of the function. A
|
| 92 |
+
copy operation associated with a return statement may be elided or
|
| 93 |
+
converted to a move operation if an automatic storage duration variable
|
| 94 |
+
is returned ([[class.copy]]). — *end note*]
|
| 95 |
+
|
| 96 |
+
[*Example 1*:
|
| 97 |
|
| 98 |
``` cpp
|
| 99 |
std::pair<std::string,int> f(const char* p, int x) {
|
| 100 |
return {p,x};
|
| 101 |
}
|
| 102 |
```
|
| 103 |
|
| 104 |
+
— *end example*]
|
|
|
|
| 105 |
|
| 106 |
+
Flowing off the end of a constructor, a destructor, or a function with a
|
| 107 |
+
cv `void` return type is equivalent to a `return` with no operand.
|
| 108 |
+
Otherwise, flowing off the end of a function other than `main` (
|
| 109 |
+
[[basic.start.main]]) results in undefined behavior.
|
| 110 |
+
|
| 111 |
+
The copy-initialization of the result of the call is sequenced before
|
| 112 |
+
the destruction of temporaries at the end of the full-expression
|
| 113 |
+
established by the operand of the return statement, which, in turn, is
|
| 114 |
+
sequenced before the destruction of local variables ([[stmt.jump]]) of
|
| 115 |
+
the block enclosing the return statement.
|
| 116 |
|
| 117 |
### The `goto` statement <a id="stmt.goto">[[stmt.goto]]</a>
|
| 118 |
|
| 119 |
The `goto` statement unconditionally transfers control to the statement
|
| 120 |
labeled by the identifier. The identifier shall be a label (
|