Skip to content

P3433R1 Allocator Support for Operation States #8002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 86 additions & 2 deletions source/exec.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,7 @@
\begin{codeblock}
[]<class Sndr, class Rcvr>(Sndr&& sndr, Rcvr& rcvr) noexcept -> decltype(auto) {
auto& [_, data, ...child] = sndr;
return std::forward_like<Sndr>(data);
return @\exposid{allocator-aware-forward}@(std::forward_like<Sndr>(data), rcvr);
}
\end{codeblock}

Expand Down Expand Up @@ -1895,6 +1895,89 @@
denoted by \tcode{\exposid{completion-signatures-for}<Sndr, Env>}
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>(env), std::forward<Sndr>(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<class T, class Context>
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<T>}.

\pnum
\returns
\begin{itemize}
\item
If \exposid{alloc} is not defined, returns \tcode{std::forward<T>(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<decltype(e)>(std::forward_like<T>(e), @\exposid{alloc}@)
\end{codeblock}
where \tcode{e} is the corresponding element of \tcode{obj},
\item
otherwise, returns \tcode{make_obj_using_allocator<P>(std::forward<T>(obj), \exposid{alloc})}.
\end{itemize}
\end{itemdescr}

\rSec2[exec.snd.concepts]{Sender concepts}

\pnum
Expand Down Expand Up @@ -3585,7 +3668,8 @@
args_variant_t @\exposid{args}@; // \expos
ops2_variant_t @\exposid{ops2}@; // \expos
};
return @\exposid{state-type}@{std::forward_like<Sndr>(fn), @\exposid{let-env}@(child), {}, {}};
return @\exposid{state-type}@{@\exposid{allocator-aware-forward}@(std::forward_like<Sndr>(fn), rcvr),
@\exposid{let-env}@(child), {}, {}};
}
\end{codeblock}

Expand Down