|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4466" status="New"> |
| 5 | +<title><tt>task</tt> should move its result</title> |
| 6 | +<section><sref ref="[task.promise]"/></section> |
| 7 | +<submitter>Robert A.H. Leahy</submitter> |
| 8 | +<date>05 Nov 2025</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<p> |
| 13 | +In <sref ref="[task.promise]"/> there's the following bullet (7.3): |
| 14 | +</p> |
| 15 | +<blockquote><pre> |
| 16 | +set_value(std::move(<i>RCVR</i>(*this)), *<i>result</i>). |
| 17 | +</pre></blockquote> |
| 18 | +<p> |
| 19 | +This has the effect of sending the result as an lvalue whereas an rvalue is almost |
| 20 | +certainly what's intended, see the bullet (7.1) above: |
| 21 | +</p> |
| 22 | +<blockquote><pre> |
| 23 | +set_error(std::move(<i>RCVR</i>(*this)), std::move(e)) […] |
| 24 | +</pre></blockquote> |
| 25 | +<p> |
| 26 | +Resolution would be to change the bullet (7.3) to: |
| 27 | +</p> |
| 28 | +<blockquote><pre> |
| 29 | +set_value(std::move(<i>RCVR</i>(*this)), *<ins>std::move(</ins><i>result</i><ins>)</ins>). |
| 30 | +</pre></blockquote> |
| 31 | +</discussion> |
| 32 | + |
| 33 | +<resolution> |
| 34 | +<p> |
| 35 | +This wording is relative to <paper num="N5014"/>. |
| 36 | +</p> |
| 37 | + |
| 38 | +<ol> |
| 39 | +<li><p>Modify <sref ref="[task.promise]"/>, as indicated:</p> |
| 40 | + |
| 41 | +<blockquote> |
| 42 | +<pre> |
| 43 | +auto final_suspend() noexcept; |
| 44 | +</pre> |
| 45 | +<blockquote> |
| 46 | +<p> |
| 47 | +-7- <i>Returns</i>: An awaitable object of unspecified type (<sref ref="[expr.await]"/>) |
| 48 | +whose member functions arrange for the completion of the asynchronous operation associated |
| 49 | +with <tt><i>STATE</i>(*this)</tt> by invoking: |
| 50 | +</p> |
| 51 | +<ul style="list-style-type: none"> |
| 52 | +<li>(7.1) — |
| 53 | +<tt>set_error(std::move(<i>RCVR</i>(*this)), std::move(e))</tt> if <tt><i>errors</i>.index()</tt> |
| 54 | +is greater than zero and `e` is the value held by <tt><i>errors</i></tt>, otherwise |
| 55 | +</li> |
| 56 | +<li>(7.2) — |
| 57 | +<tt>set_value(std::move(<i>RCVR</i>(*this)))</tt> if <tt>is_void<T></tt> is `true`, |
| 58 | +and otherwise |
| 59 | +</li> |
| 60 | +<li>(7.3) — |
| 61 | +<tt>set_value(std::move(<i>RCVR</i>(*this)), *<ins>std::move(</ins><i>result</i><ins>)</ins>)</tt>. |
| 62 | +</li> |
| 63 | +</ul> |
| 64 | +</blockquote> |
| 65 | +</blockquote> |
| 66 | +</li> |
| 67 | +</ol> |
| 68 | + |
| 69 | +</resolution> |
| 70 | + |
| 71 | +</issue> |
0 commit comments