tmp/tmpkszp_lku/{from.md → to.md}
RENAMED
|
@@ -38,16 +38,20 @@ the non-object function parameters, preceded by the type of the object
|
|
| 38 |
parameter [[dcl.fct]] if the coroutine is a non-static member function.
|
| 39 |
The promise type shall be a class type.
|
| 40 |
|
| 41 |
In the following, `pᵢ` is an lvalue of type `Pᵢ`, where `p₁` denotes the
|
| 42 |
object parameter and `p_i+1` denotes the iᵗʰ non-object function
|
| 43 |
-
parameter for
|
| 44 |
-
function parameter otherwise. For
|
| 45 |
-
an lvalue that denotes `*this`; any other `qᵢ` is an
|
| 46 |
-
the parameter copy corresponding to `pᵢ`, as
|
|
|
|
| 47 |
|
| 48 |
-
A coroutine behaves as if
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
``` bnf
|
| 51 |
'{'
|
| 52 |
*promise-type* promise *promise-constructor-arguments* ';'
|
| 53 |
% FIXME: promise'.get_return_object()' ';'
|
|
@@ -88,15 +92,19 @@ where
|
|
| 88 |
suspended at the initial await expression, and
|
| 89 |
- a coroutine is suspended at a *final suspend point* if it is suspended
|
| 90 |
- at a final await expression or
|
| 91 |
- due to an exception exiting from `unhandled_exception()`.
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
If searches for the names `return_void` and `return_value` in the scope
|
| 94 |
of the promise type each find any declarations, the program is
|
| 95 |
ill-formed.
|
| 96 |
|
| 97 |
-
[*Note
|
| 98 |
coroutine is equivalent to a `co_return` with no operand. Otherwise,
|
| 99 |
flowing off the end of a coroutine results in undefined behavior
|
| 100 |
[[stmt.return.coroutine]]. — *end note*]
|
| 101 |
|
| 102 |
The expression `promise.get_return_object()` is used to initialize the
|
|
@@ -112,20 +120,22 @@ evaluation that invoked a resumption member function is called the
|
|
| 112 |
not suspended results in undefined behavior.
|
| 113 |
|
| 114 |
An implementation may need to allocate additional storage for a
|
| 115 |
coroutine. This storage is known as the *coroutine state* and is
|
| 116 |
obtained by calling a non-array allocation function
|
| 117 |
-
[[basic.stc.dynamic.allocation]]
|
| 118 |
-
looked up by searching for it in the scope
|
|
|
|
| 119 |
|
| 120 |
- If the search finds any declarations, overload resolution is performed
|
| 121 |
on a function call created by assembling an argument list. The first
|
| 122 |
argument is the amount of space requested, and is a prvalue of type
|
| 123 |
-
`std::size_t`. The lvalues `p₁` … `pₙ`
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
| 127 |
- If the search finds no declarations, a search is performed in the
|
| 128 |
global scope. Overload resolution is performed on a function call
|
| 129 |
created by passing the amount of space required as a prvalue of type
|
| 130 |
`std::size_t`.
|
| 131 |
|
|
@@ -135,12 +145,12 @@ declarations, then the result of a call to an allocation function used
|
|
| 135 |
to obtain storage for the coroutine state is assumed to return `nullptr`
|
| 136 |
if it fails to obtain storage, and if a global allocation function is
|
| 137 |
selected, the `::operator new(size_t, nothrow_t)` form is used. The
|
| 138 |
allocation function used in this case shall have a non-throwing
|
| 139 |
*noexcept-specifier*. If the allocation function returns `nullptr`, the
|
| 140 |
-
coroutine
|
| 141 |
-
value is obtained by a call to
|
| 142 |
`T::get_return_object_on_allocation_failure()`, where `T` is the promise
|
| 143 |
type.
|
| 144 |
|
| 145 |
[*Example 2*:
|
| 146 |
|
|
@@ -204,27 +214,32 @@ usual deallocation function is found, the program is ill-formed. The
|
|
| 204 |
selected deallocation function shall be called with the address of the
|
| 205 |
block of storage to be reclaimed as its first argument. If a
|
| 206 |
deallocation function with a parameter of type `std::size_t` is used,
|
| 207 |
the size of the block is passed as the corresponding argument.
|
| 208 |
|
| 209 |
-
When a coroutine is invoked,
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
automatic storage duration that is direct-initialized from an xvalue of
|
| 213 |
-
type `T` referring to the parameter.
|
| 214 |
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
|
| 218 |
The initialization and destruction of each parameter copy occurs in the
|
| 219 |
context of the called coroutine. Initializations of parameter copies are
|
| 220 |
sequenced before the call to the coroutine promise constructor and
|
| 221 |
indeterminately sequenced with respect to each other. The lifetime of
|
| 222 |
parameter copies ends immediately after the lifetime of the coroutine
|
| 223 |
promise object ends.
|
| 224 |
|
| 225 |
-
[*Note
|
| 226 |
the coroutine after the lifetime of the entity referred to by that
|
| 227 |
parameter has ended is likely to result in undefined
|
| 228 |
behavior. — *end note*]
|
| 229 |
|
| 230 |
If the evaluation of the expression `promise.unhandled_exception()`
|
|
|
|
| 38 |
parameter [[dcl.fct]] if the coroutine is a non-static member function.
|
| 39 |
The promise type shall be a class type.
|
| 40 |
|
| 41 |
In the following, `pᵢ` is an lvalue of type `Pᵢ`, where `p₁` denotes the
|
| 42 |
object parameter and `p_i+1` denotes the iᵗʰ non-object function
|
| 43 |
+
parameter for an implicit object member function, and `pᵢ` denotes the
|
| 44 |
+
iᵗʰ function parameter otherwise. For an implicit object member
|
| 45 |
+
function, `q₁` is an lvalue that denotes `*this`; any other `qᵢ` is an
|
| 46 |
+
lvalue that denotes the parameter copy corresponding to `pᵢ`, as
|
| 47 |
+
described below.
|
| 48 |
|
| 49 |
+
A coroutine behaves as if the top-level cv-qualifiers in all
|
| 50 |
+
*parameter-declaration*s in the declarator of its *function-definition*
|
| 51 |
+
were removed and its *function-body* were replaced by the following
|
| 52 |
+
*replacement body*:
|
| 53 |
|
| 54 |
``` bnf
|
| 55 |
'{'
|
| 56 |
*promise-type* promise *promise-constructor-arguments* ';'
|
| 57 |
% FIXME: promise'.get_return_object()' ';'
|
|
|
|
| 92 |
suspended at the initial await expression, and
|
| 93 |
- a coroutine is suspended at a *final suspend point* if it is suspended
|
| 94 |
- at a final await expression or
|
| 95 |
- due to an exception exiting from `unhandled_exception()`.
|
| 96 |
|
| 97 |
+
[*Note 1*: An odr-use of a non-reference parameter in a postcondition
|
| 98 |
+
assertion of a coroutine is ill-formed
|
| 99 |
+
[[dcl.contract.func]]. — *end note*]
|
| 100 |
+
|
| 101 |
If searches for the names `return_void` and `return_value` in the scope
|
| 102 |
of the promise type each find any declarations, the program is
|
| 103 |
ill-formed.
|
| 104 |
|
| 105 |
+
[*Note 2*: If `return_void` is found, flowing off the end of a
|
| 106 |
coroutine is equivalent to a `co_return` with no operand. Otherwise,
|
| 107 |
flowing off the end of a coroutine results in undefined behavior
|
| 108 |
[[stmt.return.coroutine]]. — *end note*]
|
| 109 |
|
| 110 |
The expression `promise.get_return_object()` is used to initialize the
|
|
|
|
| 120 |
not suspended results in undefined behavior.
|
| 121 |
|
| 122 |
An implementation may need to allocate additional storage for a
|
| 123 |
coroutine. This storage is known as the *coroutine state* and is
|
| 124 |
obtained by calling a non-array allocation function
|
| 125 |
+
[[basic.stc.dynamic.allocation]] as part of the replacement body. The
|
| 126 |
+
allocation function’s name is looked up by searching for it in the scope
|
| 127 |
+
of the promise type.
|
| 128 |
|
| 129 |
- If the search finds any declarations, overload resolution is performed
|
| 130 |
on a function call created by assembling an argument list. The first
|
| 131 |
argument is the amount of space requested, and is a prvalue of type
|
| 132 |
+
`std::size_t`. The lvalues `p₁` … `pₙ` with their original types
|
| 133 |
+
(including cv-qualifiers) are the successive arguments. If no viable
|
| 134 |
+
function is found [[over.match.viable]], overload resolution is
|
| 135 |
+
performed again on a function call created by passing just the amount
|
| 136 |
+
of space required as a prvalue of type `std::size_t`.
|
| 137 |
- If the search finds no declarations, a search is performed in the
|
| 138 |
global scope. Overload resolution is performed on a function call
|
| 139 |
created by passing the amount of space required as a prvalue of type
|
| 140 |
`std::size_t`.
|
| 141 |
|
|
|
|
| 145 |
to obtain storage for the coroutine state is assumed to return `nullptr`
|
| 146 |
if it fails to obtain storage, and if a global allocation function is
|
| 147 |
selected, the `::operator new(size_t, nothrow_t)` form is used. The
|
| 148 |
allocation function used in this case shall have a non-throwing
|
| 149 |
*noexcept-specifier*. If the allocation function returns `nullptr`, the
|
| 150 |
+
coroutine transfers control to the caller of the coroutine and the
|
| 151 |
+
return value is obtained by a call to
|
| 152 |
`T::get_return_object_on_allocation_failure()`, where `T` is the promise
|
| 153 |
type.
|
| 154 |
|
| 155 |
[*Example 2*:
|
| 156 |
|
|
|
|
| 214 |
selected deallocation function shall be called with the address of the
|
| 215 |
block of storage to be reclaimed as its first argument. If a
|
| 216 |
deallocation function with a parameter of type `std::size_t` is used,
|
| 217 |
the size of the block is passed as the corresponding argument.
|
| 218 |
|
| 219 |
+
When a coroutine is invoked, a copy is created for each coroutine
|
| 220 |
+
parameter at the beginning of the replacement body. For a parameter
|
| 221 |
+
whose original declaration specified the type cv `T`,
|
|
|
|
|
|
|
| 222 |
|
| 223 |
+
- if `T` is a reference type, the copy is a reference of type cv `T`
|
| 224 |
+
bound to the same object as a parameter;
|
| 225 |
+
- otherwise, the copy is a variable of type cv `T` with automatic
|
| 226 |
+
storage duration that is direct-initialized from an xvalue of type `T`
|
| 227 |
+
referring to the parameter.
|
| 228 |
+
|
| 229 |
+
[*Note 3*: An identifier in the *function-body* that names one of these
|
| 230 |
+
parameters refers to the created copy, not the original parameter
|
| 231 |
+
[[expr.prim.id.unqual]]. — *end note*]
|
| 232 |
|
| 233 |
The initialization and destruction of each parameter copy occurs in the
|
| 234 |
context of the called coroutine. Initializations of parameter copies are
|
| 235 |
sequenced before the call to the coroutine promise constructor and
|
| 236 |
indeterminately sequenced with respect to each other. The lifetime of
|
| 237 |
parameter copies ends immediately after the lifetime of the coroutine
|
| 238 |
promise object ends.
|
| 239 |
|
| 240 |
+
[*Note 4*: If a coroutine has a parameter passed by reference, resuming
|
| 241 |
the coroutine after the lifetime of the entity referred to by that
|
| 242 |
parameter has ended is likely to result in undefined
|
| 243 |
behavior. — *end note*]
|
| 244 |
|
| 245 |
If the evaluation of the expression `promise.unhandled_exception()`
|