tmp/tmpe1tj450v/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### `execution::stopped_as_optional` <a id="exec.stopped.opt">[[exec.stopped.opt]]</a>
|
| 2 |
+
|
| 3 |
+
`stopped_as_optional` maps a sender’s stopped completion operation into
|
| 4 |
+
a value completion operation as a disengaged `optional`. The sender’s
|
| 5 |
+
value completion operation is also converted into an `optional`. The
|
| 6 |
+
result is a sender that never completes with stopped, reporting
|
| 7 |
+
cancellation by completing with a disengaged `optional`.
|
| 8 |
+
|
| 9 |
+
The name `stopped_as_optional` denotes a pipeable sender adaptor object.
|
| 10 |
+
For a subexpression `sndr`, let `Sndr` be `decltype((sndr))`. The
|
| 11 |
+
expression `stopped_as_optional(sndr)` is expression-equivalent to:
|
| 12 |
+
|
| 13 |
+
``` cpp
|
| 14 |
+
transform_sender(get-domain-early(sndr), make-sender(stopped_as_optional, {}, sndr))
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
except that `sndr` is only evaluated once.
|
| 18 |
+
|
| 19 |
+
The exposition-only class template *`impls-for`* [[exec.snd.expos]] is
|
| 20 |
+
specialized for `stopped_as_optional_t` as follows:
|
| 21 |
+
|
| 22 |
+
``` cpp
|
| 23 |
+
namespace std::execution {
|
| 24 |
+
template<>
|
| 25 |
+
struct impls-for<stopped_as_optional_t> : default-impls {
|
| 26 |
+
template<class Sndr, class... Env>
|
| 27 |
+
static consteval void check-types() {
|
| 28 |
+
default-impls::check-types<Sndr, Env...>();
|
| 29 |
+
if constexpr (!requires {
|
| 30 |
+
requires (!same_as<void, single-sender-value-type<child-type<Sndr>,
|
| 31 |
+
FWD-ENV-T(Env)...>>); })
|
| 32 |
+
throw unspecified-exception();
|
| 33 |
+
}
|
| 34 |
+
};
|
| 35 |
+
}
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
where `unspecified-exception` is a type derived from `exception`.
|
| 39 |
+
|
| 40 |
+
Let `sndr` and `env` be subexpressions such that `Sndr` is
|
| 41 |
+
`decltype((sndr))` and `Env` is `decltype((env))`. If
|
| 42 |
+
`sender-for<Sndr, stopped_as_optional_t>` is `false` then the expression
|
| 43 |
+
`stopped_as_optional.transform_sender(sndr, env)` is ill-formed;
|
| 44 |
+
otherwise, if `sender_in<child-type<Sndr>, FWD-ENV-T(Env)>` is `false`,
|
| 45 |
+
the expression `stopped_as_optional.transform_sender(sndr, env)` is
|
| 46 |
+
equivalent to `not-a-sender()`; otherwise, it is equivalent to:
|
| 47 |
+
|
| 48 |
+
``` cpp
|
| 49 |
+
auto&& [_, _, child] = sndr;
|
| 50 |
+
using V = single-sender-value-type<child-type<Sndr>, FWD-ENV-T(Env)>;
|
| 51 |
+
return let_stopped(
|
| 52 |
+
then(std::forward_like<Sndr>(child),
|
| 53 |
+
[]<class... Ts>(Ts&&... ts) noexcept(is_nothrow_constructible_v<V, Ts...>) {
|
| 54 |
+
return optional<V>(in_place, std::forward<Ts>(ts)...);
|
| 55 |
+
}),
|
| 56 |
+
[]() noexcept { return just(optional<V>()); });
|
| 57 |
+
```
|
| 58 |
+
|