|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4341" status="New"> |
| 5 | +<title>Missing rvalue reference qualification for <code>task::connect()</code></title> |
| 6 | +<section><sref ref="[task.class]"/></section> |
| 7 | +<submitter>Dietmar Kühl</submitter> |
| 8 | +<date>31 Aug 2025</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<p> |
| 13 | +Coroutines can't be copied. Thus, a <code>task</code> can be |
| 14 | +<code>connect()</code> just once. To represent that |
| 15 | +<code>task::connect()</code> should be rvalue reference qualified |
| 16 | +but currently it isn't. |
| 17 | +</p> |
| 18 | +</discussion> |
| 19 | + |
| 20 | +<resolution> |
| 21 | +<p> |
| 22 | +In the synopsis in <sref ref="[task.class]"/> add rvalue |
| 23 | +reference qualification to <code>task::connect()</code>: |
| 24 | +<blockquote><pre> |
| 25 | +namespace std::execution { |
| 26 | + template<class T, class Environment> |
| 27 | + class task { |
| 28 | + ... |
| 29 | + template<receiver Rcvr> |
| 30 | + <i>state</i><Rcvr> connect(Rcvr&& rcvr) <ins>&&</ins>; |
| 31 | + ... |
| 32 | + } |
| 33 | +} |
| 34 | +</pre></blockquote> |
| 35 | +</p> |
| 36 | +<p> |
| 37 | +In the specification in <sref ref="[task.members]"/> paragraph 3 add rvalue |
| 38 | +reference qualification to <code>task::connect()</code>: |
| 39 | +<blockquote> |
| 40 | +<pre> |
| 41 | +template<receiver Rcvr> |
| 42 | + <i>state</i><Rcvr> connect(Rcvr&& rcvr) <ins>&&</ins>; |
| 43 | +</pre> |
| 44 | +<p>-3- <i>Precondition</i>: <code>bool(handle)</code> is <code>true</code>.</p> |
| 45 | +<p>-4- <i>Effects</i>: Equivalent to:</p> |
| 46 | +<pre> return state<Rcvr>(exchange(handle, {}), std::forward<Rcvr>(recv));</pre> |
| 47 | +</blockquote> |
| 48 | +</p> |
| 49 | +</resolution> |
| 50 | + |
| 51 | +</issue> |
0 commit comments