|
| 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<class T, class Promise> |
| 42 | + concept <i>has-as-awaitable</i> = <i>// exposition only</i> |
| 43 | + requires (T&& t, Promise& p) { |
| 44 | + { std::forward<T>(t).as_awaitable(p) } -> is-awaitable<Promise&>; |
| 45 | + }; |
| 46 | + |
| 47 | + template<class Derived> |
| 48 | + struct <i>with-await-transform</i> { <i>// exposition only</i> |
| 49 | + template<class T> |
| 50 | + T&& await_transform(T&& value) noexcept { |
| 51 | + return std::forward<T>(value); |
| 52 | + } |
| 53 | + |
| 54 | + template<has-as-awaitable<Derived> T> |
| 55 | + <del>decltype(auto)</del><ins>auto</ins> await_transform(T&& value) |
| 56 | + noexcept(noexcept(std::forward<T>(value).as_awaitable(declval<Derived&>()))) |
| 57 | + <ins>-> decltype(std::forward<T>(value).as_awaitable(declval<Derived&>()))</ins> { |
| 58 | + return std::forward<T>(value).as_awaitable(static_cast<Derived&>(*this)); |
| 59 | + } |
| 60 | + }; |
| 61 | +} |
| 62 | +</code></pre> |
| 63 | +</blockquote> |
| 64 | +</li> |
| 65 | +</ol> |
| 66 | +</resolution> |
| 67 | + |
| 68 | +</issue> |
0 commit comments