tmp/tmp0sl_ewmc/{from.md → to.md}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
### The `return` statement <a id="stmt.return">[[stmt.return]]</a>
|
| 2 |
|
| 3 |
-
A function returns to its caller by the `return` statement.
|
| 4 |
|
| 5 |
The *expr-or-braced-init-list* of a `return` statement is called its
|
| 6 |
operand. A `return` statement with no operand shall be used only in a
|
| 7 |
function whose return type is cv `void`, a constructor [[class.ctor]],
|
| 8 |
or a destructor [[class.dtor]]. A `return` statement with an operand of
|
|
@@ -47,5 +47,37 @@ The copy-initialization of the result of the call is sequenced before
|
|
| 47 |
the destruction of temporaries at the end of the full-expression
|
| 48 |
established by the operand of the `return` statement, which, in turn, is
|
| 49 |
sequenced before the destruction of local variables [[stmt.jump]] of the
|
| 50 |
block enclosing the `return` statement.
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
### The `return` statement <a id="stmt.return">[[stmt.return]]</a>
|
| 2 |
|
| 3 |
+
A function returns control to its caller by the `return` statement.
|
| 4 |
|
| 5 |
The *expr-or-braced-init-list* of a `return` statement is called its
|
| 6 |
operand. A `return` statement with no operand shall be used only in a
|
| 7 |
function whose return type is cv `void`, a constructor [[class.ctor]],
|
| 8 |
or a destructor [[class.dtor]]. A `return` statement with an operand of
|
|
|
|
| 47 |
the destruction of temporaries at the end of the full-expression
|
| 48 |
established by the operand of the `return` statement, which, in turn, is
|
| 49 |
sequenced before the destruction of local variables [[stmt.jump]] of the
|
| 50 |
block enclosing the `return` statement.
|
| 51 |
|
| 52 |
+
[*Note 3*: These operations are sequenced before the destruction of
|
| 53 |
+
local variables in each remaining enclosing block of the function
|
| 54 |
+
[[stmt.dcl]], which, in turn, is sequenced before the evaluation of
|
| 55 |
+
postcondition assertions of the function [[dcl.contract.func]], which,
|
| 56 |
+
in turn, is sequenced before the destruction of function parameters
|
| 57 |
+
[[expr.call]]. — *end note*]
|
| 58 |
+
|
| 59 |
+
In a function whose return type is a reference, other than an invented
|
| 60 |
+
function for `std::is_convertible` [[meta.rel]], a `return` statement
|
| 61 |
+
that binds the returned reference to a temporary expression
|
| 62 |
+
[[class.temporary]] is ill-formed.
|
| 63 |
+
|
| 64 |
+
[*Example 2*:
|
| 65 |
+
|
| 66 |
+
``` cpp
|
| 67 |
+
auto&& f1() {
|
| 68 |
+
return 42; // ill-formed
|
| 69 |
+
}
|
| 70 |
+
const double& f2() {
|
| 71 |
+
static int x = 42;
|
| 72 |
+
return x; // ill-formed
|
| 73 |
+
}
|
| 74 |
+
auto&& id(auto&& r) {
|
| 75 |
+
return static_cast<decltype(r)&&>(r);
|
| 76 |
+
}
|
| 77 |
+
auto&& f3() {
|
| 78 |
+
return id(42); // OK, but probably a bug
|
| 79 |
+
}
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
— *end example*]
|
| 83 |
+
|