tmp/tmpik72i7_5/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="coroutine.handle.general">[[coroutine.handle.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<>
|
| 6 |
+
struct coroutine_handle<void>
|
| 7 |
+
{
|
| 8 |
+
// [coroutine.handle.con], construct/reset
|
| 9 |
+
constexpr coroutine_handle() noexcept;
|
| 10 |
+
constexpr coroutine_handle(nullptr_t) noexcept;
|
| 11 |
+
coroutine_handle& operator=(nullptr_t) noexcept;
|
| 12 |
+
|
| 13 |
+
// [coroutine.handle.export.import], export/import
|
| 14 |
+
constexpr void* address() const noexcept;
|
| 15 |
+
static constexpr coroutine_handle from_address(void* addr);
|
| 16 |
+
|
| 17 |
+
// [coroutine.handle.observers], observers
|
| 18 |
+
constexpr explicit operator bool() const noexcept;
|
| 19 |
+
bool done() const;
|
| 20 |
+
|
| 21 |
+
// [coroutine.handle.resumption], resumption
|
| 22 |
+
void operator()() const;
|
| 23 |
+
void resume() const;
|
| 24 |
+
void destroy() const;
|
| 25 |
+
|
| 26 |
+
private:
|
| 27 |
+
void* ptr; // exposition only
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
template<class Promise>
|
| 31 |
+
struct coroutine_handle
|
| 32 |
+
{
|
| 33 |
+
// [coroutine.handle.con], construct/reset
|
| 34 |
+
constexpr coroutine_handle() noexcept;
|
| 35 |
+
constexpr coroutine_handle(nullptr_t) noexcept;
|
| 36 |
+
static coroutine_handle from_promise(Promise&);
|
| 37 |
+
coroutine_handle& operator=(nullptr_t) noexcept;
|
| 38 |
+
|
| 39 |
+
// [coroutine.handle.export.import], export/import
|
| 40 |
+
constexpr void* address() const noexcept;
|
| 41 |
+
static constexpr coroutine_handle from_address(void* addr);
|
| 42 |
+
|
| 43 |
+
// [coroutine.handle.conv], conversion
|
| 44 |
+
constexpr operator coroutine_handle<>() const noexcept;
|
| 45 |
+
|
| 46 |
+
// [coroutine.handle.observers], observers
|
| 47 |
+
constexpr explicit operator bool() const noexcept;
|
| 48 |
+
bool done() const;
|
| 49 |
+
|
| 50 |
+
// [coroutine.handle.resumption], resumption
|
| 51 |
+
void operator()() const;
|
| 52 |
+
void resume() const;
|
| 53 |
+
void destroy() const;
|
| 54 |
+
|
| 55 |
+
// [coroutine.handle.promise], promise access
|
| 56 |
+
Promise& promise() const;
|
| 57 |
+
|
| 58 |
+
private:
|
| 59 |
+
void* ptr; // exposition only
|
| 60 |
+
};
|
| 61 |
+
}
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
An object of type `coroutine_handle<T>` is called a *coroutine handle*
|
| 65 |
+
and can be used to refer to a suspended or executing coroutine. A
|
| 66 |
+
`coroutine_handle` object whose member `address()` returns a null
|
| 67 |
+
pointer value does not refer to any coroutine. Two `coroutine_handle`
|
| 68 |
+
objects refer to the same coroutine if and only if their member
|
| 69 |
+
`address()` returns the same non-null value.
|
| 70 |
+
|
| 71 |
+
If a program declares an explicit or partial specialization of
|
| 72 |
+
`coroutine_handle`, the behavior is undefined.
|
| 73 |
+
|