Skip to content

Commit 404165d

Browse files
committed
New issue from Eric: Alias template connect_result_t should be constrained with sender_to
1 parent d8ede75 commit 404165d

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

xml/issue4206.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4206" status="New">
5+
<title>Alias template `connect_result_t` should be constrained with `sender_to`</title>
6+
<section><sref ref="[exec.syn]"/></section>
7+
<submitter>Eric Niebler</submitter>
8+
<date>04 Feb 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
Imported from <a href="https://github.com/cplusplus/sender-receiver/issues/320">cplusplus/sender-receiver #320</a>.
14+
</p>
15+
<p>
16+
Since turning `execution::connect(sndr, rcvr)`'s <i>constraints</i>
17+
to a <i>mandates</i>, the `connect` customization point is now unconstrained.
18+
</p>
19+
<p>
20+
But there is at least one place in the algorithms (<sref ref="[exec.let]"/>)
21+
that is using `connect_result_t` in an immediate context of a function template
22+
with the expectation that <code>connect_result_t&lt;Sndr, Rcvr&gt;</code>
23+
will be well-formed only when `Sndr` and `Rcvr` can actually be connected.
24+
with the current definition, <code>connect_result_t&lt;Sndr, Rcvr&gt;</code>
25+
could very well cause a hard error; it will never cuase a substitution failure.
26+
</p>
27+
<p>
28+
The solution is to constrain the `connect_result_t` alias template.
29+
Just as <code>completion_signatures_of_t&lt;Sndr, Env&gt;</code>
30+
is constrained with <code>sender_in&lt;Sndr, Env&gt;</code>,
31+
so too should <code>connect_result_t&lt;Sndr, Rcvr&gt;</code>
32+
be constrained with <code>sender_to&lt;Sndr, Rcvr&gt;</code>.
33+
</p>
34+
<p>
35+
For reference, the `sender_to` concept is defined as follows:
36+
37+
<pre><code>
38+
template&lt;class Sndr, class Rcvr&gt;
39+
concept sender_to =
40+
sender_in&lt;Sndr, env_of_t&lt;Rcvr&gt;&gt; &amp;&amp;
41+
receiver_of&lt;Rcvr, completion_signatures_of_t&lt;Sndr, env_of_t&lt;Rcvr&gt;&gt;&gt; &amp;&amp;
42+
requires (Sndr&amp;&amp; sndr, Rcvr&amp;&amp; rcvr) {
43+
connect(std::forward&lt;Sndr&gt;(sndr), std::forward&lt;Rcvr&gt;(rcvr));
44+
};
45+
</code></pre>
46+
</p>
47+
48+
</discussion>
49+
50+
<resolution>
51+
<p>
52+
This wording is relative to <paper num="N5001"/>.
53+
</p>
54+
55+
<ol>
56+
<li>
57+
Modify <sref ref="[exec.syn]"/> as indicated:
58+
<blockquote>
59+
<pre><code>
60+
template&lt;class Sndr, class Rcvr&gt;
61+
<ins>requires sender_to&lt;Sndr, Rcvr&gt;</ins>
62+
using connect_result_t =
63+
decltype(connect(declval&lt;Sndr&gt;(), declval&lt;Rcvr&gt;()));
64+
</code></pre>
65+
</blockquote>
66+
</li>
67+
</ol>
68+
69+
</resolution>
70+
71+
</issue>

0 commit comments

Comments
 (0)