Skip to content

Commit 23a1e66

Browse files
committed
P3433R1 Allocator Support for Operation States
Fixes #7957 Fixes cplusplus/papers#2098
1 parent 2e12f5e commit 23a1e66

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

source/exec.tex

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@
18191819
\begin{codeblock}
18201820
[]<class Sndr, class Rcvr>(Sndr&& sndr, Rcvr& rcvr) noexcept -> decltype(auto) {
18211821
auto& [_, data, ...child] = sndr;
1822-
return std::forward_like<Sndr>(data);
1822+
return @\exposid{allocator-aware-forward}@(std::forward_like<Sndr>(data), rcvr);
18231823
}
18241824
\end{codeblock}
18251825

@@ -1916,6 +1916,36 @@
19161916
\end{itemize}
19171917
\end{itemdescr}
19181918

1919+
\begin{itemdecl}
1920+
template<class T, class Context>
1921+
decltype(auto) @\exposid{allocator-aware-forward}@(T&& obj, Context&& context); // \expos
1922+
\end{itemdecl}
1923+
1924+
\begin{itemdescr}
1925+
\pnum
1926+
\exposid{allocator-aware-forward} is an exposition-only function used to
1927+
either create a new object of type \tcode{T} from \tcode{obj}
1928+
or forward \tcode{obj} depending on whether an allocator is available.
1929+
If the environment associated with context provides an allocator
1930+
(i.e., the expression \tcode{get_allocator(get_env(context))} is valid,
1931+
let \exposid{alloc} be the result of this expression
1932+
and \tcode{P} be \tcode{remove_cvref_t<T>}.
1933+
1934+
\pnum
1935+
\returns
1936+
\begin{itemize}
1937+
\item
1938+
If \exposid{alloc} is not defined, returns \tcode{std::forward<T>(obj)},
1939+
\item
1940+
otherwise if \tcode{P} is a specialization of \exposid{product-type},
1941+
returns an object of type \tcode{P} whose elements are initialized using
1942+
\tcode{make_obj_using_allocator<decltype(e)> (std::forward_like<T>(e), \exposid{alloc})}
1943+
where \tcode{e} is the corresponding element of \tcode{obj},
1944+
\item
1945+
otherwise, returns \tcode{make_obj_using_allocator<P>(std::forward<T>(obj), \exposid{alloc})}.
1946+
\end{itemize}
1947+
\end{itemdescr}
1948+
19191949
\rSec2[exec.snd.concepts]{Sender concepts}
19201950

19211951
\pnum
@@ -3515,7 +3545,8 @@
35153545
args_variant_t @\exposid{args}@; // \expos
35163546
ops2_variant_t @\exposid{ops2}@; // \expos
35173547
};
3518-
return @\exposid{state-type}@{std::forward_like<Sndr>(fn), @\exposid{let-env}@(child), {}, {}};
3548+
return @\exposid{state-type}@{@\exposid{allocator-aware-forward}@(std::forward_like<Sndr>(fn), rcvr),
3549+
@\exposid{let-env}@(child), {}, {}};
35193550
}
35203551
\end{codeblock}
35213552

0 commit comments

Comments
 (0)