|
1849 | 1849 | \begin{codeblock}
|
1850 | 1850 | []<class Sndr, class Rcvr>(Sndr&& sndr, Rcvr& rcvr) noexcept -> decltype(auto) {
|
1851 | 1851 | auto& [_, data, ...child] = sndr;
|
1852 |
| - return std::forward_like<Sndr>(data); |
| 1852 | + return @\exposid{allocator-aware-forward}@(std::forward_like<Sndr>(data), rcvr); |
1853 | 1853 | }
|
1854 | 1854 | \end{codeblock}
|
1855 | 1855 |
|
|
1895 | 1895 | denoted by \tcode{\exposid{completion-signatures-for}<Sndr, Env>}
|
1896 | 1896 | to communicate to users why.
|
1897 | 1897 |
|
| 1898 | +\begin{itemdecl} |
| 1899 | +template<@\libconcept{sender}@ Sndr, @\exposconcept{queryable}@ Env> |
| 1900 | + constexpr auto @\exposid{write-env}@(Sndr&& sndr, Env&& env); // \expos |
| 1901 | +\end{itemdecl} |
| 1902 | + |
| 1903 | +\begin{itemdescr} |
| 1904 | +\pnum |
| 1905 | +\exposid{write-env} is an exposition-only sender adaptor that, |
| 1906 | +when connected with a receiver \tcode{rcvr}, |
| 1907 | +connects the adapted sender with a receiver |
| 1908 | +whose execution environment is the result of |
| 1909 | +joining the \exposconcept{queryable} argument \tcode{env} |
| 1910 | +to the result of \tcode{get_env(rcvr)}. |
| 1911 | + |
| 1912 | +\pnum |
| 1913 | +Let \exposid{write-env-t} be an exposition-only empty class type. |
| 1914 | + |
| 1915 | +\pnum |
| 1916 | +\returns |
| 1917 | +\begin{codeblock} |
| 1918 | +@\exposid{make-sender}@(@\exposid{write-env-t}@(), std::forward<Env>(env), std::forward<Sndr>(sndr)) |
| 1919 | +\end{codeblock} |
| 1920 | + |
| 1921 | +\pnum |
| 1922 | +\remarks |
| 1923 | +The exposition-only class template \exposid{impls-for}\iref{exec.snd.general} |
| 1924 | +is specialized for \exposid{write-env-t} as follows: |
| 1925 | +\begin{codeblock} |
| 1926 | +template<> |
| 1927 | +struct @\exposid{impls-for}@<@\exposid{write-env-t}@> : @\exposid{default-impls}@ { |
| 1928 | + static constexpr auto @\exposid{get-env}@ = |
| 1929 | + [](auto, const auto& state, const auto& rcvr) noexcept { |
| 1930 | + return @\seebelow@; |
| 1931 | + }; |
| 1932 | +}; |
| 1933 | +\end{codeblock} |
| 1934 | +Invocation of |
| 1935 | +\tcode{\exposid{impls-for}<\exposid{write-env-t}>::\exposid{get-env}} |
| 1936 | +returns an object \tcode{e} such that |
| 1937 | +\begin{itemize} |
| 1938 | +\item |
| 1939 | +\tcode{decltype(e)} models \exposconcept{queryable} and |
| 1940 | +\item |
| 1941 | +given a query object \tcode{q}, |
| 1942 | +the expression \tcode{e.query(q)} is expression-equivalent |
| 1943 | +to \tcode{state.query(q)} if that expression is valid, |
| 1944 | +otherwise, \tcode{e.query(q)} is expression-equivalent |
| 1945 | +to \tcode{get_env(rcvr).que\-ry(q)}. |
| 1946 | +\end{itemize} |
| 1947 | +\end{itemdescr} |
| 1948 | + |
| 1949 | +\begin{itemdecl} |
| 1950 | +template<class T, class Context> |
| 1951 | + decltype(auto) @\exposid{allocator-aware-forward}@(T&& obj, Context&& context); // \expos |
| 1952 | +\end{itemdecl} |
| 1953 | + |
| 1954 | +\begin{itemdescr} |
| 1955 | +\pnum |
| 1956 | +\exposid{allocator-aware-forward} is an exposition-only function used to |
| 1957 | +either create a new object of type \tcode{T} from \tcode{obj} |
| 1958 | +or forward \tcode{obj} depending on whether an allocator is available. |
| 1959 | +If the environment associated with context provides an allocator |
| 1960 | +(i.e., the expression \tcode{get_allocator(get_env(context))} is valid, |
| 1961 | +let \exposid{alloc} be the result of this expression |
| 1962 | +and \tcode{P} be \tcode{remove_cvref_t<T>}. |
| 1963 | + |
| 1964 | +\pnum |
| 1965 | +\returns |
| 1966 | +\begin{itemize} |
| 1967 | +\item |
| 1968 | +If \exposid{alloc} is not defined, returns \tcode{std::forward<T>(obj)}, |
| 1969 | +\item |
| 1970 | +otherwise if \tcode{P} is a specialization of \exposid{product-type}, |
| 1971 | +returns an object of type \tcode{P} whose elements are initialized using |
| 1972 | +\tcode{make_obj_using_allocator<decltype(e)> (std::forward_like<T>(e), \exposid{alloc})} |
| 1973 | +where \tcode{e} is the corresponding element of \tcode{obj}, |
| 1974 | +\item |
| 1975 | +otherwise, returns \tcode{make_obj_using_allocator<P>(std::forward<T>(obj), \exposid{alloc})}. |
| 1976 | +\end{itemize} |
| 1977 | +\end{itemdescr} |
| 1978 | + |
1898 | 1979 | \rSec2[exec.snd.concepts]{Sender concepts}
|
1899 | 1980 |
|
1900 | 1981 | \pnum
|
|
3585 | 3666 | args_variant_t @\exposid{args}@; // \expos
|
3586 | 3667 | ops2_variant_t @\exposid{ops2}@; // \expos
|
3587 | 3668 | };
|
3588 |
| - return @\exposid{state-type}@{std::forward_like<Sndr>(fn), @\exposid{let-env}@(child), {}, {}}; |
| 3669 | + return @\exposid{state-type}@{@\exposid{allocator-aware-forward}@(std::forward_like<Sndr>(fn), rcvr), |
| 3670 | + @\exposid{let-env}@(child), {}, {}}; |
3589 | 3671 | }
|
3590 | 3672 | \end{codeblock}
|
3591 | 3673 |
|
|
0 commit comments