|
1816 | 1816 |
|
1817 | 1817 | \rSec2[exec.snd.concepts]{Sender concepts}
|
1818 | 1818 |
|
| 1819 | +\pnum |
| 1820 | +The \libconcept{sender} concept defines |
| 1821 | +the requirements for a sender type\iref{exec.async.ops}. |
| 1822 | +The \libconcept{sender_in} concept defines |
| 1823 | +the requirements for a sender type |
| 1824 | +that can create asynchronous operations given an associated environment type. |
| 1825 | +The \libconcept{sender_to} concept defines |
| 1826 | +the requirements for a sender type |
| 1827 | +that can connect with a specific receiver type. |
| 1828 | +The \tcode{get_env} customization point object is used to access |
| 1829 | +a sender's associated attributes. |
| 1830 | +The connect customization point object is used to connect\iref{exec.async.ops} |
| 1831 | +a sender and a receiver to produce an operation state. |
| 1832 | + |
| 1833 | +\begin{codeblock} |
| 1834 | +namespace std::execution { |
| 1835 | + template<class Sigs> |
| 1836 | + concept @\exposconcept{valid-completion-signatures}@ = @\seebelow@; // \expos |
| 1837 | + |
| 1838 | + template<class Sndr> |
| 1839 | + concept @\defexposconcept{is-sender}@ = // \expos |
| 1840 | + derived_from<typename Sndr::sender_concept, sender_t>; |
| 1841 | + |
| 1842 | + template<class Sndr> |
| 1843 | + concept @\defexposconcept{enable-sender}@ = // \expos |
| 1844 | + @\exposconcept{is-sender}@<Sndr> || |
| 1845 | + @\exposconcept{is-awaitable}@<Sndr, @\exposconcept{env-promise}@<empty_env>>; // \ref{exec.awaitables} |
| 1846 | + |
| 1847 | + template<class Sndr> |
| 1848 | + concept @\deflibconcept{sender}@ = |
| 1849 | + bool(@\exposconcept{enable-sender}@<remove_cvref_t<Sndr>>) && |
| 1850 | + requires (const remove_cvref_t<Sndr>& sndr) { |
| 1851 | + { get_env(sndr) } -> @\exposconcept{queryable}@; |
| 1852 | + } && |
| 1853 | + @\libconcept{move_constructible}@<remove_cvref_t<Sndr>> && |
| 1854 | + @\libconcept{constructible_from}@<remove_cvref_t<Sndr>, Sndr>; |
| 1855 | + |
| 1856 | + template<class Sndr, class Env = empty_env> |
| 1857 | + concept @\deflibconcept{sender_in}@ = |
| 1858 | + @\libconcept{sender}@<Sndr> && |
| 1859 | + @\exposconcept{queryable}@<Env> && |
| 1860 | + requires (Sndr&& sndr, Env&& env) { |
| 1861 | + { get_completion_signatures(std::forward<Sndr>(sndr), std::forward<Env>(env)) } |
| 1862 | + -> @\exposconcept{valid-completion-signatures}@; |
| 1863 | + }; |
| 1864 | + |
| 1865 | + template<class Sndr, class Rcvr> |
| 1866 | + concept @\deflibconcept{sender_to}@ = |
| 1867 | + @\libconcept{sender_in}@<Sndr, env_of_t<Rcvr>> && |
| 1868 | + @\libconcept{receiver_of}@<Rcvr, completion_signatures_of_t<Sndr, env_of_t<Rcvr>>> && |
| 1869 | + requires (Sndr&& sndr, Rcvr&& rcvr) { |
| 1870 | + connect(std::forward<Sndr>(sndr), std::forward<Rcvr>(rcvr)); |
| 1871 | + }; |
| 1872 | +} |
| 1873 | +\end{codeblock} |
| 1874 | + |
| 1875 | +\pnum |
| 1876 | +Given a subexpression \tcode{sndr}, |
| 1877 | +let \tcode{Sndr} be \tcode{decltype((sndr))} and |
| 1878 | +let \tcode{rcvr} be a receiver |
| 1879 | +with an associated environment whose type is \tcode{Env}. |
| 1880 | +A completion operation is a \defnadj{permissible}{completion} |
| 1881 | +for \tcode{Sndr} and \tcode{Env} |
| 1882 | +if its completion signature appears in the argument list of the specialization of \tcode{completion_signatures} denoted by |
| 1883 | +\tcode{completion_signatures_of_t<Sndr, Env>}. |
| 1884 | +\tcode{Sndr} and \tcode{Env} model \tcode{\libconcept{sender_in}<Sndr, Env>} |
| 1885 | +if all the completion operations |
| 1886 | +that are potentially evaluated by connecting \tcode{sndr} to \tcode{rcvr} and |
| 1887 | +starting the resulting operation state |
| 1888 | +are permissible completions for \tcode{Sndr} and \tcode{Env}. |
| 1889 | + |
| 1890 | +\pnum |
| 1891 | +A type models |
| 1892 | +the exposition-only concept \exposconcept{valid-completion-signatures} |
| 1893 | +if it denotes a specialization of |
| 1894 | +the \tcode{completion_signatures} class template. |
| 1895 | + |
| 1896 | +\pnum |
| 1897 | +The exposition-only concepts |
| 1898 | +\exposconcept{sender-of} and \exposconcept{sender-in-of} |
| 1899 | +define the requirements for a sender type |
| 1900 | +that completes with a given unique set of value result types. |
| 1901 | +\begin{codeblock} |
| 1902 | +namespace std::execution { |
| 1903 | + template<class... As> |
| 1904 | + using @\exposid{value-signature}@ = set_value_t(As...); // \expos |
| 1905 | + |
| 1906 | + template<class Sndr, class Env, class... Values> |
| 1907 | + concept @\defexposconcept{sender-in-of}@ = |
| 1908 | + @\libconcept{sender_in}@<Sndr, Env> && |
| 1909 | + @\exposid{MATCHING-SIG}@( // see \ref{exec.general} |
| 1910 | + set_value_t(Values...), |
| 1911 | + value_types_of_t<Sndr, Env, @\exposid{value-signature}@, type_identity_t>); |
| 1912 | + |
| 1913 | + template<class Sndr, class... Values> |
| 1914 | + concept @\defexposconcept{sender-of}@ = @\exposconcept{sender-in-of}@<Sndr, empty_env, Values...>; |
| 1915 | +} |
| 1916 | +\end{codeblock} |
| 1917 | + |
| 1918 | +\pnum |
| 1919 | +Let \tcode{sndr} be an expression |
| 1920 | +such that \tcode{decltype((sndr))} is \tcode{Sndr}. |
| 1921 | +The type \tcode{tag_of_t<Sndr>} is as follows: |
| 1922 | +\begin{itemize} |
| 1923 | +\item |
| 1924 | +If the declaration |
| 1925 | +\begin{codeblock} |
| 1926 | +auto&& [tag, data, ...children] = sndr; |
| 1927 | +\end{codeblock} |
| 1928 | +would be well-formed, \tcode{tag_of_t<Sndr>} is |
| 1929 | +an alias for \tcode{decltype(auto(tag))}. |
| 1930 | +\item |
| 1931 | +Otherwise, \tcode{tag_of_t<Sndr>} is ill-formed. |
| 1932 | +\end{itemize} |
| 1933 | + |
| 1934 | +\pnum |
| 1935 | +Let \exposconcept{sender-for} be an exposition-only concept defined as follows: |
| 1936 | +\begin{codeblock} |
| 1937 | +namespace std::execution { |
| 1938 | + template<class Sndr, class Tag> |
| 1939 | + concept @\exposconcept{sender-for}@ = |
| 1940 | + @\libconcept{sender}@<Sndr> && |
| 1941 | + @\libconcept{same_as}@<tag_of_t<Sndr>, Tag>; |
| 1942 | +} |
| 1943 | +\end{codeblock} |
| 1944 | + |
| 1945 | +\pnum |
| 1946 | +For a type \tcode{T}, |
| 1947 | +\tcode{\exposid{SET-VALUE-SIG}(T)} denotes the type \tcode{set_value_t()} |
| 1948 | +if \tcode{T} is \cv{} \tcode{void}; |
| 1949 | +otherwise, it denotes the type \tcode{set_value_t(T)}. |
| 1950 | + |
| 1951 | +\pnum |
| 1952 | +Library-provided sender types |
| 1953 | +\begin{itemize} |
| 1954 | +\item |
| 1955 | +always expose an overload of a member \tcode{connect} |
| 1956 | +that accepts an rvalue sender and |
| 1957 | +\item |
| 1958 | +only expose an overload of a member \tcode{connect} |
| 1959 | +that accepts an lvalue sender if they model \tcode{copy_constructible}. |
| 1960 | +\end{itemize} |
| 1961 | + |
| 1962 | +\rSec2[exec.awaitable]{Awaitable helpers} |
| 1963 | + |
1819 | 1964 | \rSec1[exec.util]{Sender/receiver utilities}
|
1820 | 1965 |
|
1821 | 1966 | \rSec1[exec.ctx]{Execution contexts}
|
|
0 commit comments