|
| 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<Sndr, Rcvr></code> |
| 23 | +will be well-formed only when `Sndr` and `Rcvr` can actually be connected. |
| 24 | +with the current definition, <code>connect_result_t<Sndr, Rcvr></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<Sndr, Env></code> |
| 30 | +is constrained with <code>sender_in<Sndr, Env></code>, |
| 31 | +so too should <code>connect_result_t<Sndr, Rcvr></code> |
| 32 | +be constrained with <code>sender_to<Sndr, Rcvr></code>. |
| 33 | +</p> |
| 34 | +<p> |
| 35 | +For reference, the `sender_to` concept is defined as follows: |
| 36 | + |
| 37 | +<pre><code> |
| 38 | +template<class Sndr, class Rcvr> |
| 39 | + concept sender_to = |
| 40 | + sender_in<Sndr, env_of_t<Rcvr>> && |
| 41 | + receiver_of<Rcvr, completion_signatures_of_t<Sndr, env_of_t<Rcvr>>> && |
| 42 | + requires (Sndr&& sndr, Rcvr&& rcvr) { |
| 43 | + connect(std::forward<Sndr>(sndr), std::forward<Rcvr>(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<class Sndr, class Rcvr> |
| 61 | + <ins>requires sender_to<Sndr, Rcvr></ins> |
| 62 | + using connect_result_t = |
| 63 | + decltype(connect(declval<Sndr>(), declval<Rcvr>())); |
| 64 | +</code></pre> |
| 65 | +</blockquote> |
| 66 | +</li> |
| 67 | +</ol> |
| 68 | + |
| 69 | +</resolution> |
| 70 | + |
| 71 | +</issue> |
0 commit comments