#
then attaches an invocable as a continuation for an input sender's value completion operation.
upon_error and upon_stopped do the same for the error and stopped completion operations, respectively, sending the result of the invocable as a value completion.
2
#
The names then, upon_error, and upon_stopped denote pipeable sender adaptor objects.
Let the expression then-cpo be one of then, upon_error, or upon_stopped.
For subexpressions sndr and f, if decltype(sndr)) does not satisfy sender, or decltype(f)) does not satisfy movable-value, then-cpo(sndr, f) is ill-formed.
Otherwise, the expression then-cpo(sndr, f) is expression-equivalent to: transform_sender(get-domain-early(sndr), make-sender(then-cpo, f, sndr)) except that sndr is evaluated only once.
For then, upon_error, and upon_stopped, let set-cpo be set_value, set_error, and set_stopped, respectively.
The exposition-only class template impls-for ([exec.snd.expos]) is specialized for then-cpo as follows: namespace std::execution { template<> struct impls-for<decayed-typeof<then-cpo>> : default-impls { static constexpr auto complete = []<class Tag, class. Args> (auto, auto& fn, auto& rcvr, Tag, Args&&. args) noexcept -> void { if constexpr (same_as<Tag, decayed-typeof<set-cpo>>) { TRY-SET-VALUE(rcvr, invoke(std::move(fn), std::forward<Args>(args).); } else { Tag()(std::move(rcvr), std::forward<Args>(args).); } }; template<class Sndr, class. Env> static consteval void check-types(); }; }
template<class Sndr, class. Env> static consteval void check-types();
Effects: Equivalent to: auto cs = get_completion_signatures<child-type<Sndr>, FWD-ENV-T(Env).>(); auto fn = []<class. Ts>(decayed-typeof<set-cpo>(*)(Ts..) { if constexpr (!invocable<remove_cvref_t<data-type<Sndr>>, Ts..>) throw unspecified-exception(); }; cs.for-each(overload-set{fn, [](auto){});
The expression then-cpo(sndr, f) has undefined behavior unless it returns a sender out_sndr that
  • invokes f or a copy of such with the value, error, or stopped result datums of sndr for then, upon_error, and upon_stopped, respectively, using the result value of f as out_sndr's value completion, and
  • forwards all other completion operations unchanged.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant