diff --git a/source/exec.tex b/source/exec.tex index 8258d089ad..b2af5a89b7 100644 --- a/source/exec.tex +++ b/source/exec.tex @@ -1849,7 +1849,7 @@ \begin{codeblock} [](Sndr&& sndr, Rcvr& rcvr) noexcept -> decltype(auto) { auto& [_, data, ...child] = sndr; - return std::forward_like(data); + return @\exposid{allocator-aware-forward}@(std::forward_like(data), rcvr); } \end{codeblock} @@ -1895,6 +1895,89 @@ denoted by \tcode{\exposid{completion-signatures-for}} to communicate to users why. +\begin{itemdecl} +template<@\libconcept{sender}@ Sndr, @\exposconcept{queryable}@ Env> + constexpr auto @\exposid{write-env}@(Sndr&& sndr, Env&& env); // \expos +\end{itemdecl} + +\begin{itemdescr} +\pnum +\exposid{write-env} is an exposition-only sender adaptor that, +when connected with a receiver \tcode{rcvr}, +connects the adapted sender with a receiver +whose execution environment is the result of +joining the \exposconcept{queryable} argument \tcode{env} +to the result of \tcode{get_env(rcvr)}. + +\pnum +Let \exposid{write-env-t} be an exposition-only empty class type. + +\pnum +\returns +\begin{codeblock} +@\exposid{make-sender}@(@\exposid{write-env-t}@(), std::forward(env), std::forward(sndr)) +\end{codeblock} + +\pnum +\remarks +The exposition-only class template \exposid{impls-for}\iref{exec.snd.general} +is specialized for \exposid{write-env-t} as follows: +\begin{codeblock} +template<> +struct @\exposid{impls-for}@<@\exposid{write-env-t}@> : @\exposid{default-impls}@ { + static constexpr auto @\exposid{get-env}@ = + [](auto, const auto& state, const auto& rcvr) noexcept { + return @\seebelow@; + }; +}; +\end{codeblock} +Invocation of +\tcode{\exposid{impls-for}<\exposid{write-env-t}>::\exposid{get-env}} +returns an object \tcode{e} such that +\begin{itemize} +\item +\tcode{decltype(e)} models \exposconcept{queryable} and +\item +given a query object \tcode{q}, +the expression \tcode{e.query(q)} is expression-equivalent +to \tcode{state.query(q)} if that expression is valid, +otherwise, \tcode{e.query(q)} is expression-equivalent +to \tcode{get_env(rcvr).que\-ry(q)}. +\end{itemize} +\end{itemdescr} + +\begin{itemdecl} +template + decltype(auto) @\exposid{allocator-aware-forward}@(T&& obj, Context&& context); // \expos +\end{itemdecl} + +\begin{itemdescr} +\pnum +\exposid{allocator-aware-forward} is an exposition-only function used to +either create a new object of type \tcode{T} from \tcode{obj} +or forward \tcode{obj} depending on whether an allocator is available. +If the environment associated with \tcode{context} provides an allocator +(i.e., the expression \tcode{get_allocator(get_env(context))} is valid, +let \exposid{alloc} be the result of this expression +and let \tcode{P} be \tcode{remove_cvref_t}. + +\pnum +\returns +\begin{itemize} +\item +If \exposid{alloc} is not defined, returns \tcode{std::forward(obj)}, +\item +otherwise if \tcode{P} is a specialization of \exposid{product-type}, +returns an object of type \tcode{P} whose elements are initialized using +\begin{codeblock} +make_obj_using_allocator(std::forward_like(e), @\exposid{alloc}@) +\end{codeblock} +where \tcode{e} is the corresponding element of \tcode{obj}, +\item +otherwise, returns \tcode{make_obj_using_allocator

(std::forward(obj), \exposid{alloc})}. +\end{itemize} +\end{itemdescr} + \rSec2[exec.snd.concepts]{Sender concepts} \pnum @@ -3585,7 +3668,8 @@ args_variant_t @\exposid{args}@; // \expos ops2_variant_t @\exposid{ops2}@; // \expos }; - return @\exposid{state-type}@{std::forward_like(fn), @\exposid{let-env}@(child), {}, {}}; + return @\exposid{state-type}@{@\exposid{allocator-aware-forward}@(std::forward_like(fn), rcvr), + @\exposid{let-env}@(child), {}, {}}; } \end{codeblock}