tmp/tmpew66243y/{from.md → to.md}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
### Class `generator::promise_type` <a id="coro.generator.promise">[[coro.generator.promise]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
-
template<class Ref, class
|
| 6 |
-
class generator<Ref,
|
| 7 |
public:
|
| 8 |
generator get_return_object() noexcept;
|
| 9 |
|
| 10 |
suspend_always initial_suspend() const noexcept { return {}; }
|
| 11 |
auto final_suspend() noexcept;
|
|
@@ -17,29 +17,30 @@ namespace std {
|
|
| 17 |
constructible_from<remove_cvref_t<yielded>, const remove_reference_t<yielded>&>;
|
| 18 |
|
| 19 |
template<class R2, class V2, class Alloc2, class Unused>
|
| 20 |
requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded>
|
| 21 |
auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&&, Unused> g) noexcept;
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
template<ranges::input_range R, class Alloc>
|
| 24 |
requires convertible_to<ranges::range_reference_t<R>, yielded>
|
| 25 |
-
auto yield_value(ranges::elements_of<R, Alloc> r)
|
| 26 |
|
| 27 |
void await_transform() = delete;
|
| 28 |
|
| 29 |
void return_void() const noexcept {}
|
| 30 |
void unhandled_exception();
|
| 31 |
|
| 32 |
void* operator new(size_t size)
|
| 33 |
requires same_as<Allocator, void> || default_initializable<Allocator>;
|
| 34 |
|
| 35 |
template<class Alloc, class... Args>
|
| 36 |
-
requires same_as<Allocator, void> || convertible_to<const Alloc&, Allocator>
|
| 37 |
void* operator new(size_t size, allocator_arg_t, const Alloc& alloc, const Args&...);
|
| 38 |
|
| 39 |
template<class This, class Alloc, class... Args>
|
| 40 |
-
requires same_as<Allocator, void> || convertible_to<const Alloc&, Allocator>
|
| 41 |
void* operator new(size_t size, const This&, allocator_arg_t, const Alloc& alloc,
|
| 42 |
const Args&...);
|
| 43 |
|
| 44 |
void operator delete(void* pointer, size_t size) noexcept;
|
| 45 |
|
|
@@ -106,10 +107,13 @@ object.
|
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
template<class R2, class V2, class Alloc2, class Unused>
|
| 109 |
requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded>
|
| 110 |
auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&&, Unused> g) noexcept;
|
|
|
|
|
|
|
|
|
|
| 111 |
```
|
| 112 |
|
| 113 |
*Preconditions:* A handle referring to the coroutine whose promise
|
| 114 |
object is `*this` is at the top of `*`*`active_`* of some `generator`
|
| 115 |
object `x`. The coroutine referred to by `g.range.`*`coroutine_`* is
|
|
@@ -122,24 +126,24 @@ into which `g.range` is moved, whose member `await_ready` returns
|
|
| 122 |
execution of the coroutine referred to by `g.range.`*`coroutine_`*, and
|
| 123 |
whose member `await_resume` evaluates `rethrow_exception(`*`except_`*`)`
|
| 124 |
if `bool(`*`except_`*`)` is `true`. If `bool(`*`except_`*`)` is `false`,
|
| 125 |
the `await_resume` member has no effects.
|
| 126 |
|
| 127 |
-
*Remarks:* A *yield-expression* that calls
|
| 128 |
-
[[expr.yield]].
|
| 129 |
|
| 130 |
``` cpp
|
| 131 |
template<ranges::input_range R, class Alloc>
|
| 132 |
requires convertible_to<ranges::range_reference_t<R>, yielded>
|
| 133 |
-
auto yield_value(ranges::elements_of<R, Alloc> r)
|
| 134 |
```
|
| 135 |
|
| 136 |
*Effects:* Equivalent to:
|
| 137 |
|
| 138 |
``` cpp
|
| 139 |
auto nested = [](allocator_arg_t, Alloc, ranges::iterator_t<R> i, ranges::sentinel_t<R> s)
|
| 140 |
-
-> generator<yielded,
|
| 141 |
for (; i != s; ++i) {
|
| 142 |
co_yield static_cast<yielded>(*i);
|
| 143 |
}
|
| 144 |
};
|
| 145 |
return yield_value(ranges::elements_of(nested(
|
|
@@ -164,15 +168,13 @@ is `*this` is the sole element of `*x.`*`active_`*, equivalent to
|
|
| 164 |
``` cpp
|
| 165 |
void* operator new(size_t size)
|
| 166 |
requires same_as<Allocator, void> || default_initializable<Allocator>;
|
| 167 |
|
| 168 |
template<class Alloc, class... Args>
|
| 169 |
-
requires same_as<Allocator, void> || convertible_to<const Alloc&, Allocator>
|
| 170 |
void* operator new(size_t size, allocator_arg_t, const Alloc& alloc, const Args&...);
|
| 171 |
|
| 172 |
template<class This, class Alloc, class... Args>
|
| 173 |
-
requires same_as<Allocator, void> || convertible_to<const Alloc&, Allocator>
|
| 174 |
void* operator new(size_t size, const This&, allocator_arg_t, const Alloc& alloc,
|
| 175 |
const Args&...);
|
| 176 |
```
|
| 177 |
|
| 178 |
Let `A` be
|
|
@@ -183,11 +185,14 @@ Let `A` be
|
|
| 183 |
|
| 184 |
Let `B` be `allocator_traits<A>::template rebind_alloc<U>` where `U` is
|
| 185 |
an unspecified type whose size and alignment are both
|
| 186 |
\_\_STDCPP_DEFAULT_NEW_ALIGNMENT\_\_.
|
| 187 |
|
| 188 |
-
*Mandates:* `allocator_traits<B>::pointer` is a pointer type.
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
*Effects:* Initializes an allocator `b` of type `B` with `A(alloc)`, for
|
| 191 |
the overloads with a function parameter `alloc`, and with `A()`
|
| 192 |
otherwise. Uses `b` to allocate storage for the smallest array of `U`
|
| 193 |
sufficient to provide storage for a coroutine state of size `size`, and
|
|
|
|
| 1 |
### Class `generator::promise_type` <a id="coro.generator.promise">[[coro.generator.promise]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
+
template<class Ref, class Val, class Allocator>
|
| 6 |
+
class generator<Ref, Val, Allocator>::promise_type {
|
| 7 |
public:
|
| 8 |
generator get_return_object() noexcept;
|
| 9 |
|
| 10 |
suspend_always initial_suspend() const noexcept { return {}; }
|
| 11 |
auto final_suspend() noexcept;
|
|
|
|
| 17 |
constructible_from<remove_cvref_t<yielded>, const remove_reference_t<yielded>&>;
|
| 18 |
|
| 19 |
template<class R2, class V2, class Alloc2, class Unused>
|
| 20 |
requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded>
|
| 21 |
auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&&, Unused> g) noexcept;
|
| 22 |
+
template<class R2, class V2, class Alloc2, class Unused>
|
| 23 |
+
requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded>
|
| 24 |
+
auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&, Unused> g) noexcept;
|
| 25 |
|
| 26 |
template<ranges::input_range R, class Alloc>
|
| 27 |
requires convertible_to<ranges::range_reference_t<R>, yielded>
|
| 28 |
+
auto yield_value(ranges::elements_of<R, Alloc> r);
|
| 29 |
|
| 30 |
void await_transform() = delete;
|
| 31 |
|
| 32 |
void return_void() const noexcept {}
|
| 33 |
void unhandled_exception();
|
| 34 |
|
| 35 |
void* operator new(size_t size)
|
| 36 |
requires same_as<Allocator, void> || default_initializable<Allocator>;
|
| 37 |
|
| 38 |
template<class Alloc, class... Args>
|
|
|
|
| 39 |
void* operator new(size_t size, allocator_arg_t, const Alloc& alloc, const Args&...);
|
| 40 |
|
| 41 |
template<class This, class Alloc, class... Args>
|
|
|
|
| 42 |
void* operator new(size_t size, const This&, allocator_arg_t, const Alloc& alloc,
|
| 43 |
const Args&...);
|
| 44 |
|
| 45 |
void operator delete(void* pointer, size_t size) noexcept;
|
| 46 |
|
|
|
|
| 107 |
|
| 108 |
``` cpp
|
| 109 |
template<class R2, class V2, class Alloc2, class Unused>
|
| 110 |
requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded>
|
| 111 |
auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&&, Unused> g) noexcept;
|
| 112 |
+
template<class R2, class V2, class Alloc2, class Unused>
|
| 113 |
+
requires same_as<typename generator<R2, V2, Alloc2>::yielded, yielded>
|
| 114 |
+
auto yield_value(ranges::elements_of<generator<R2, V2, Alloc2>&, Unused> g) noexcept;
|
| 115 |
```
|
| 116 |
|
| 117 |
*Preconditions:* A handle referring to the coroutine whose promise
|
| 118 |
object is `*this` is at the top of `*`*`active_`* of some `generator`
|
| 119 |
object `x`. The coroutine referred to by `g.range.`*`coroutine_`* is
|
|
|
|
| 126 |
execution of the coroutine referred to by `g.range.`*`coroutine_`*, and
|
| 127 |
whose member `await_resume` evaluates `rethrow_exception(`*`except_`*`)`
|
| 128 |
if `bool(`*`except_`*`)` is `true`. If `bool(`*`except_`*`)` is `false`,
|
| 129 |
the `await_resume` member has no effects.
|
| 130 |
|
| 131 |
+
*Remarks:* A *yield-expression* that calls one of these functions has
|
| 132 |
+
type `void` [[expr.yield]].
|
| 133 |
|
| 134 |
``` cpp
|
| 135 |
template<ranges::input_range R, class Alloc>
|
| 136 |
requires convertible_to<ranges::range_reference_t<R>, yielded>
|
| 137 |
+
auto yield_value(ranges::elements_of<R, Alloc> r);
|
| 138 |
```
|
| 139 |
|
| 140 |
*Effects:* Equivalent to:
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
auto nested = [](allocator_arg_t, Alloc, ranges::iterator_t<R> i, ranges::sentinel_t<R> s)
|
| 144 |
+
-> generator<yielded, void, Alloc> {
|
| 145 |
for (; i != s; ++i) {
|
| 146 |
co_yield static_cast<yielded>(*i);
|
| 147 |
}
|
| 148 |
};
|
| 149 |
return yield_value(ranges::elements_of(nested(
|
|
|
|
| 168 |
``` cpp
|
| 169 |
void* operator new(size_t size)
|
| 170 |
requires same_as<Allocator, void> || default_initializable<Allocator>;
|
| 171 |
|
| 172 |
template<class Alloc, class... Args>
|
|
|
|
| 173 |
void* operator new(size_t size, allocator_arg_t, const Alloc& alloc, const Args&...);
|
| 174 |
|
| 175 |
template<class This, class Alloc, class... Args>
|
|
|
|
| 176 |
void* operator new(size_t size, const This&, allocator_arg_t, const Alloc& alloc,
|
| 177 |
const Args&...);
|
| 178 |
```
|
| 179 |
|
| 180 |
Let `A` be
|
|
|
|
| 185 |
|
| 186 |
Let `B` be `allocator_traits<A>::template rebind_alloc<U>` where `U` is
|
| 187 |
an unspecified type whose size and alignment are both
|
| 188 |
\_\_STDCPP_DEFAULT_NEW_ALIGNMENT\_\_.
|
| 189 |
|
| 190 |
+
*Mandates:* `allocator_traits<B>::pointer` is a pointer type. For the
|
| 191 |
+
overloads with a template parameter `Alloc`,
|
| 192 |
+
`same_as<Allocator, void> || convertible_to<const Alloc&, Allocator>` is
|
| 193 |
+
modeled.
|
| 194 |
|
| 195 |
*Effects:* Initializes an allocator `b` of type `B` with `A(alloc)`, for
|
| 196 |
the overloads with a function parameter `alloc`, and with `A()`
|
| 197 |
otherwise. Uses `b` to allocate storage for the smallest array of `U`
|
| 198 |
sufficient to provide storage for a coroutine state of size `size`, and
|