From Jason Turner

[exec.then]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3km8cle8/{from.md → to.md} +75 -0
tmp/tmp3km8cle8/{from.md → to.md} RENAMED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### `execution::then`, `execution::upon_error`, `execution::upon_stopped` <a id="exec.then">[[exec.then]]</a>
2
+
3
+ `then` attaches an invocable as a continuation for an input sender’s
4
+ value completion operation. `upon_error` and `upon_stopped` do the same
5
+ for the error and stopped completion operations, respectively, sending
6
+ the result of the invocable as a value completion.
7
+
8
+ The names `then`, `upon_error`, and `upon_stopped` denote pipeable
9
+ sender adaptor objects. Let the expression *`then-cpo`* be one of
10
+ `then`, `upon_error`, or `upon_stopped`. For subexpressions `sndr` and
11
+ `f`, if `decltype((sndr))` does not satisfy `sender`, or `decltype((f))`
12
+ does not satisfy `movable-value`, `then-cpo(sndr, f) `is ill-formed.
13
+
14
+ Otherwise, the expression `then-cpo(sndr, f)` is expression-equivalent
15
+ to:
16
+
17
+ ``` cpp
18
+ transform_sender(get-domain-early(sndr), make-sender(then-cpo, f, sndr))
19
+ ```
20
+
21
+ except that `sndr` is evaluated only once.
22
+
23
+ For `then`, `upon_error`, and `upon_stopped`, let *`set-cpo`* be
24
+ `set_value`, `set_error`, and `set_stopped`, respectively. The
25
+ exposition-only class template *`impls-for`* [[exec.snd.expos]] is
26
+ specialized for *`then-cpo`* as follows:
27
+
28
+ ``` cpp
29
+ namespace std::execution {
30
+ template<>
31
+ struct impls-for<decayed-typeof<then-cpo>> : default-impls {
32
+ static constexpr auto complete =
33
+ []<class Tag, class... Args>
34
+ (auto, auto& fn, auto& rcvr, Tag, Args&&... args) noexcept -> void {
35
+ if constexpr (same_as<Tag, decayed-typeof<set-cpo>>) {
36
+ TRY-SET-VALUE(rcvr,
37
+ invoke(std::move(fn), std::forward<Args>(args)...));
38
+ } else {
39
+ Tag()(std::move(rcvr), std::forward<Args>(args)...);
40
+ }
41
+ };
42
+
43
+ template<class Sndr, class... Env>
44
+ static consteval void check-types();
45
+ };
46
+ }
47
+ ```
48
+
49
+ ``` cpp
50
+ template<class Sndr, class... Env>
51
+ static consteval void check-types();
52
+ ```
53
+
54
+ *Effects:* Equivalent to:
55
+
56
+ ``` cpp
57
+ auto cs = get_completion_signatures<child-type<Sndr>, FWD-ENV-T(Env)...>();
58
+ auto fn = []<class... Ts>(set_value_t(*)(Ts...)) {
59
+ if constexpr (!invocable<remove_cvref_t<data-type<Sndr>>, Ts...>)
60
+ throw unspecified-exception();
61
+ };
62
+ cs.for-each(overload-set{fn, [](auto){}});
63
+ ```
64
+
65
+ where *`unspecified-exception`* is a type derived from `exception`.
66
+
67
+ The expression `then-cpo(sndr, f)` has undefined behavior unless it
68
+ returns a sender `out_sndr` that
69
+
70
+ - invokes `f` or a copy of such with the value, error, or stopped result
71
+ datums of `sndr` for `then`, `upon_error`, and `upon_stopped`,
72
+ respectively, using the result value of `f` as `out_sndr`’s value
73
+ completion, and
74
+ - forwards all other completion operations unchanged.
75
+