Skip to content

Commit 4854977

Browse files
committed
New issue from Brian Bi: with-await-transform::await_transform should not use a deduced return type
1 parent cf1c9e9 commit 4854977

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

xml/issue4201.xml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4201" status="New">
5+
<title>`with-await-transform::await_transform` should not use a deduced return type</title>
6+
<section><sref ref="[exec.awaitable]"/></section>
7+
<submitter>Brian Bi</submitter>
8+
<date>03 Feb 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
Imported from <a href="https://github.com/cplusplus/sender-receiver/issues/309">cplusplus/sender-receiver #309</a>.
14+
</p>
15+
<p>
16+
<sref ref="[exec.awaitable]"/>/p5
17+
</p>
18+
<p>
19+
The use of the deduced return type causes the definition of the sender's
20+
`as_awaitable` method to be instantiated too early,
21+
e.g., when the sender is passed to `get_completion_signatures`.
22+
</p>
23+
24+
<note>Eric provides wording</note>
25+
26+
</discussion>
27+
28+
<resolution>
29+
<p>
30+
This wording is relative to <paper num="N5001"/>.
31+
</p>
32+
<ol>
33+
<li>
34+
Modify <sref ref="[exec.awaitable]"/> as indicated:
35+
<blockquote>
36+
-5-
37+
Let <i><code>with-await-transform</code></i> be the exposition-only class template:
38+
39+
<pre><code>
40+
namespace std::execution {
41+
template&lt;class T, class Promise&gt;
42+
concept <i>has-as-awaitable</i> = <i>// exposition only</i>
43+
requires (T&amp;&amp; t, Promise&amp; p) {
44+
{ std::forward&lt;T&gt;(t).as_awaitable(p) } -&gt; is-awaitable&lt;Promise&amp;&gt;;
45+
};
46+
47+
template&lt;class Derived&gt;
48+
struct <i>with-await-transform</i> { <i>// exposition only</i>
49+
template&lt;class T&gt;
50+
T&amp;&amp; await_transform(T&amp;&amp; value) noexcept {
51+
return std::forward&lt;T&gt;(value);
52+
}
53+
54+
template&lt;has-as-awaitable&lt;Derived&gt; T&gt;
55+
<del>decltype(auto)</del><ins>auto</ins> await_transform(T&amp;&amp; value)
56+
noexcept(noexcept(std::forward&lt;T&gt;(value).as_awaitable(declval&lt;Derived&amp;&gt;())))
57+
<ins>-&gt; decltype(std::forward&lt;T&gt;(value).as_awaitable(declval&lt;Derived&amp;&gt;()))</ins> {
58+
return std::forward&lt;T&gt;(value).as_awaitable(static_cast&lt;Derived&amp;&gt;(*this));
59+
}
60+
};
61+
}
62+
</code></pre>
63+
</blockquote>
64+
</li>
65+
</ol>
66+
</resolution>
67+
68+
</issue>

0 commit comments

Comments
 (0)