tmp/tmpho4yucar/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Completion signatures <a id="exec.cmplsig">[[exec.cmplsig]]</a>
|
| 2 |
+
|
| 3 |
+
`completion_signatures` is a type that encodes a set of completion
|
| 4 |
+
signatures [[exec.async.ops]].
|
| 5 |
+
|
| 6 |
+
[*Example 1*:
|
| 7 |
+
|
| 8 |
+
``` cpp
|
| 9 |
+
struct my_sender {
|
| 10 |
+
using sender_concept = sender_t;
|
| 11 |
+
using completion_signatures =
|
| 12 |
+
execution::completion_signatures<
|
| 13 |
+
set_value_t(),
|
| 14 |
+
set_value_t(int, float),
|
| 15 |
+
set_error_t(exception_ptr),
|
| 16 |
+
set_error_t(error_code),
|
| 17 |
+
set_stopped_t()>;
|
| 18 |
+
};
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
Declares `my_sender` to be a sender that can complete by calling one of
|
| 22 |
+
the following for a receiver expression `rcvr`:
|
| 23 |
+
|
| 24 |
+
- `set_value(rcvr)`
|
| 25 |
+
- `set_value(rcvr, int{...}, float{...})`
|
| 26 |
+
- `set_error(rcvr, exception_ptr{...})`
|
| 27 |
+
- `set_error(rcvr, error_code{...})`
|
| 28 |
+
- `set_stopped(rcvr)`
|
| 29 |
+
|
| 30 |
+
— *end example*]
|
| 31 |
+
|
| 32 |
+
This subclause makes use of the following exposition-only entities:
|
| 33 |
+
|
| 34 |
+
``` cpp
|
| 35 |
+
template<class Fn>
|
| 36 |
+
concept completion-signature = see below;
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
A type `Fn` satisfies `completion-signature` if and only if it is a
|
| 40 |
+
function type with one of the following forms:
|
| 41 |
+
|
| 42 |
+
- `set_value_t(Vs...)`, where `Vs` is a pack of object or reference
|
| 43 |
+
types.
|
| 44 |
+
- `set_error_t(Err)`, where `Err` is an object or reference type.
|
| 45 |
+
- `set_stopped_t()`
|
| 46 |
+
|
| 47 |
+
``` cpp
|
| 48 |
+
template<bool>
|
| 49 |
+
struct indirect-meta-apply {
|
| 50 |
+
template<template<class...> class T, class... As>
|
| 51 |
+
using meta-apply = T<As...>; // exposition only
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
template<class...>
|
| 55 |
+
concept always-true = true; // exposition only
|
| 56 |
+
|
| 57 |
+
template<class Tag,
|
| 58 |
+
valid-completion-signatures Completions,
|
| 59 |
+
template<class...> class Tuple,
|
| 60 |
+
template<class...> class Variant>
|
| 61 |
+
using gather-signatures = see below;
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
Let `Fns` be a pack of the arguments of the `completion_signatures`
|
| 65 |
+
specialization named by `Completions`, let `TagFns` be a pack of the
|
| 66 |
+
function types in `Fns` whose return types are `Tag`, and let `Tsₙ` be a
|
| 67 |
+
pack of the function argument types in the n-th type in `TagFns`. Then,
|
| 68 |
+
given two variadic templates `Tuple` and `Variant`, the type
|
| 69 |
+
`gather-signatures<Tag, Completions, Tuple, Variant>` names the type
|
| 70 |
+
|
| 71 |
+
``` cpp
|
| 72 |
+
META-APPLY(Variant, META-APPLY(Tuple, Ts_0...),
|
| 73 |
+
META-APPLY(Tuple, Ts_1...),
|
| 74 |
+
…,
|
| 75 |
+
META-APPLY(Tuple, Ts_{m-1}...))
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
where m is the size of the pack `TagFns` and `META-APPLY(T, As...)` is
|
| 79 |
+
equivalent to:
|
| 80 |
+
|
| 81 |
+
``` cpp
|
| 82 |
+
typename indirect-meta-apply<always-true<As...>>::template meta-apply<T, As...>
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
[*Note 1*: The purpose of *`META-APPLY`* is to make it valid to use
|
| 86 |
+
non-variadic templates as `Variant` and `Tuple` arguments to
|
| 87 |
+
*`gather-signatures`*. — *end note*]
|
| 88 |
+
|
| 89 |
+
``` cpp
|
| 90 |
+
namespace std::execution {
|
| 91 |
+
template<completion-signature... Fns>
|
| 92 |
+
struct completion_signatures {
|
| 93 |
+
template<class Tag>
|
| 94 |
+
static constexpr size_t count-of(Tag) { return see below; }
|
| 95 |
+
|
| 96 |
+
template<class Fn>
|
| 97 |
+
static constexpr void for-each(Fn&& fn) { // exposition only
|
| 98 |
+
(std::forward<Fn>(fn)(static_cast<Fns*>(nullptr)), ...);
|
| 99 |
+
}
|
| 100 |
+
};
|
| 101 |
+
|
| 102 |
+
template<class Sndr, class Env = env<>,
|
| 103 |
+
template<class...> class Tuple = decayed-tuple,
|
| 104 |
+
template<class...> class Variant = variant-or-empty>
|
| 105 |
+
requires sender_in<Sndr, Env>
|
| 106 |
+
using value_types_of_t =
|
| 107 |
+
gather-signatures<set_value_t, completion_signatures_of_t<Sndr, Env>, Tuple, Variant>;
|
| 108 |
+
|
| 109 |
+
template<class Sndr, class Env = env<>,
|
| 110 |
+
template<class...> class Variant = variant-or-empty>
|
| 111 |
+
requires sender_in<Sndr, Env>
|
| 112 |
+
using error_types_of_t =
|
| 113 |
+
gather-signatures<set_error_t, completion_signatures_of_t<Sndr, Env>,
|
| 114 |
+
type_identity_t, Variant>;
|
| 115 |
+
|
| 116 |
+
template<class Sndr, class Env = env<>>
|
| 117 |
+
requires sender_in<Sndr, Env>
|
| 118 |
+
constexpr bool sends_stopped =
|
| 119 |
+
!same_as<type-list<>,
|
| 120 |
+
gather-signatures<set_stopped_t, completion_signatures_of_t<Sndr, Env>,
|
| 121 |
+
type-list, type-list>>;
|
| 122 |
+
}
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
For a subexpression `tag`, let `Tag` be the decayed type of `tag`.
|
| 126 |
+
`completion_signatures<Fns...>::count-of({}tag)` returns the count of
|
| 127 |
+
function types in `Fns...` that are of the form `Tag(Ts...)` where `Ts`
|
| 128 |
+
is a pack of types.
|
| 129 |
+
|