|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4355" status="New"> |
| 5 | +<title><tt><i>connect-awaitable()</i></tt> should mandate `rcvr` can receive all completion-signals rather than using constraints</title> |
| 6 | +<section> |
| 7 | +<sref ref="[exec.connect]"/> |
| 8 | +</section> |
| 9 | +<submitter>Lewis Baker</submitter> |
| 10 | +<date>27 Aug 2025</date> |
| 11 | +<priority>99</priority> |
| 12 | + |
| 13 | +<discussion> |
| 14 | +<p> |
| 15 | +In <sref ref="[exec.connect]"/> p6, the wording for the `connect()` customization-point defines a case that is |
| 16 | +expression-equivalent to <tt><i>connect-awaitable</i>(new_sndr, rcvr)</tt>. |
| 17 | +<p/> |
| 18 | +The <tt><i>connect-awaitable</i></tt> function is specified in p5 as having the signature: |
| 19 | +</p> |
| 20 | +<blockquote><pre> |
| 21 | +<i>operation-state-task</i> <i>connect-awaitable</i>(DS sndr, DR rcvr) requires receiver_of<DR, Sigs>; |
| 22 | +</pre></blockquote> |
| 23 | +<p> |
| 24 | +The requires-clause constrains this overload to ensure that the receiver, `rcvr`, can accept all of the |
| 25 | +completion signatures listed in `Sigs`. This means that `connect()` will SFINAE out if the receiver cannot |
| 26 | +accept all of the completion signatures, rather than this being ill-formed. |
| 27 | +<p/> |
| 28 | +However, this seems inconsistent with the handling of the case that dispatches to <tt>new-sndr.connect(rcvr)</tt> |
| 29 | +which does not constrain on this. It is also redundant with the <i>Mandates</i> element in p6 which mandates |
| 30 | +that the following is satisfied: |
| 31 | +</p> |
| 32 | +<blockquote><pre> |
| 33 | +receiver_of<Rcvr, completion_signatures_of_t<Sndr, env_of_t<Rcvr>>> |
| 34 | +</pre></blockquote> |
| 35 | +<p> |
| 36 | +The constraint on <tt><i>connect-awaitable</i></tt> should either be removed or replaced with a |
| 37 | +<i>Mandates</i> element. As <tt><i>connect-awaitable</i></tt> is only used within the definition of |
| 38 | +<tt>connect()</tt> and as <tt>connect()</tt> already mandates that `receiver_of` is satisfied, |
| 39 | +it seems sufficient to just remove this constraint from <tt><i>connect-awaitable</i></tt>. |
| 40 | +</p> |
| 41 | +</discussion> |
| 42 | + |
| 43 | +<resolution> |
| 44 | +<p> |
| 45 | +This wording is relative to <paper num="N5014"/>. |
| 46 | +</p> |
| 47 | + |
| 48 | +<ol> |
| 49 | + |
| 50 | +<li><p>Modify <sref ref="[exec.connect]"/> as indicated:</p> |
| 51 | + |
| 52 | +<blockquote> |
| 53 | +<p> |
| 54 | +-5- Let `V` name the type <tt><i>await-result-type</i><DS, <i>connect-awaitable-promise</i>></tt>, |
| 55 | +let `Sigs` name the type |
| 56 | +</p> |
| 57 | +<blockquote><pre> |
| 58 | +completion_signatures< |
| 59 | + <i>SET-VALUE-SIG</i>(V), // <i>see <sref ref="[exec.snd.concepts]"/></i> |
| 60 | + set_error_t(exception_ptr), |
| 61 | + set_stopped_t()> |
| 62 | +</pre></blockquote> |
| 63 | +<p> |
| 64 | +and let <tt><i>connect-awaitable</i></tt> be an exposition-only coroutine defined as follows: |
| 65 | +</p> |
| 66 | +<blockquote><pre> |
| 67 | +namespace std::execution { |
| 68 | + […] |
| 69 | + <i>operation-state-task</i> <i>connect-awaitable</i>(DS sndr, DR rcvr) <del>requires receiver_of<DR, Sigs></del> { |
| 70 | + exception_ptr ep; |
| 71 | + try { |
| 72 | + if constexpr (same_as<V, void>) { |
| 73 | + co_await std::move(sndr); |
| 74 | + co_await <i>suspend-complete</i>(set_value, std::move(rcvr)); |
| 75 | + } else { |
| 76 | + co_await <i>suspend-complete</i>(set_value, std::move(rcvr), co_await std::move(sndr)); |
| 77 | + } |
| 78 | + } catch(...) { |
| 79 | + ep = current_exception(); |
| 80 | + } |
| 81 | + co_await <i>suspend-complete</i>(set_error, std::move(rcvr), std::move(ep)); |
| 82 | + } |
| 83 | +} |
| 84 | +</pre></blockquote> |
| 85 | +<p> |
| 86 | +</p> |
| 87 | +</blockquote> |
| 88 | + |
| 89 | +</li> |
| 90 | + |
| 91 | +</ol> |
| 92 | +</resolution> |
| 93 | + |
| 94 | +</issue> |
0 commit comments