|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4363" status="New"> |
| 5 | +<title>`transform_sender` comparing types ignoring <i>cv</i>-qualifiers doesn't take into account differences in value category</title> |
| 6 | +<section> |
| 7 | +<sref ref="[exec.snd.transform]"/> |
| 8 | +</section> |
| 9 | +<submitter>Lewis Baker</submitter> |
| 10 | +<date>28 Aug 2025</date> |
| 11 | +<priority>99</priority> |
| 12 | + |
| 13 | +<discussion> |
| 14 | +<p> |
| 15 | +In <sref ref="[exec.snd.transform]"/> p1, the specification for `transform_sender()` states: |
| 16 | +</p> |
| 17 | +<blockquote> |
| 18 | +<p> |
| 19 | +Let <tt><i>transformed-sndr</i></tt> be the expression |
| 20 | +</p> |
| 21 | +<blockquote><pre> |
| 22 | +dom.transform_sender(std::forward<Sndr>(sndr), env...) |
| 23 | +</pre></blockquote> |
| 24 | +<p> |
| 25 | +if that expression is well-formed; otherwise, |
| 26 | +</p> |
| 27 | +<blockquote><pre> |
| 28 | +default_domain().transform_sender(std::forward<Sndr>(sndr), env...) |
| 29 | +</pre></blockquote> |
| 30 | +<p> |
| 31 | +Let <tt><i>final-sndr</i></tt> be the expression <tt><i>transformed-sndr</i></tt> if |
| 32 | +<tt><i>transformed-sndr</i></tt> and <tt><i>sndr</i></tt> have the same type ignoring |
| 33 | +cv-qualifiers; otherwise, it is the expression <tt>transform_sender(dom, <i>transformed-sndr</i>, env...)</tt>. |
| 34 | +</p> |
| 35 | +</blockquote> |
| 36 | +<p> |
| 37 | +However, the use of the phrase "have the same type ignoring cv-qualifiers" asks to compare |
| 38 | +the types without `const` or `volatile` qualifiers, but doesn't take into account differences |
| 39 | +in value category of the types of these expressions. |
| 40 | +<p/> |
| 41 | +For example `sndr` might have type <tt>T&&</tt> and <tt><i>transformed-sndr</i></tt> |
| 42 | +might return a new prvalue of type `T`. |
| 43 | +<p/> |
| 44 | +My interpretation of the current wording is that I should apply the test |
| 45 | +<tt>same_as<remove_cv_t<decltype(sndr)>, remove_cv_t<decltype(<i>transformed-sndr</i>)>></tt>. |
| 46 | +<p/> |
| 47 | +However, `remove_cv_t` does not remove reference-qualifiers from a type <tt>Sndr&&</tt> |
| 48 | +(which in the above example, is the type of `sndr`), and thus would compare as different to |
| 49 | +a <tt><i>transform-sndr</i></tt> type of `Sndr`. |
| 50 | +<p/> |
| 51 | +I believe the intention is that this should instead use |
| 52 | +<tt>same_as<remove_cvref_t<decltype(sndr)>, remove_cvref_t<decltype(<i>transformed-sndr</i>)>></tt>. |
| 53 | +For example, the |
| 54 | +<a href="https://github.com/NVIDIA/stdexec/blob/4669060ad3b70508740449f9c30f06867a9bd890/include/stdexec/__detail/__transform_sender.hpp#L88"> |
| 55 | +implementation</a> in NVIDIA's stdexec repository uses <tt>same_as<decay_t<T>, decay_t<U>></tt> |
| 56 | +for this check. |
| 57 | +<p/> |
| 58 | +The wording should be modified to use a phrase that removes both reference and cv-qualifiers when comparing types. |
| 59 | +</p> |
| 60 | +</discussion> |
| 61 | + |
| 62 | +<resolution> |
| 63 | +<p> |
| 64 | +This wording is relative to <paper num="N5014"/>. |
| 65 | +</p> |
| 66 | + |
| 67 | +<ol> |
| 68 | + |
| 69 | +<li><p>Modify <sref ref="[exec.snd.transform]"/> as indicated:</p> |
| 70 | + |
| 71 | +<blockquote> |
| 72 | +<pre> |
| 73 | +namespace std::execution { |
| 74 | + template<class Domain, sender Sndr, <i>queryable</i>... Env> |
| 75 | + requires (sizeof...(Env) <= 1) |
| 76 | + constexpr sender decltype(auto) transform_sender(Domain dom, Sndr&& sndr, const Env&... env) |
| 77 | + noexcept(<i>see below</i>); |
| 78 | +} |
| 79 | +</pre> |
| 80 | +<blockquote> |
| 81 | +<p> |
| 82 | +-1- Let <tt><i>transformed-sndr</i></tt> be the expression |
| 83 | +</p> |
| 84 | +<blockquote><pre> |
| 85 | +dom.transform_sender(std::forward<Sndr>(sndr), env...) |
| 86 | +</pre></blockquote> |
| 87 | +<p> |
| 88 | +if that expression is well-formed; otherwise, |
| 89 | +</p> |
| 90 | +<blockquote><pre> |
| 91 | +default_domain().transform_sender(std::forward<Sndr>(sndr), env...) |
| 92 | +</pre></blockquote> |
| 93 | +<p> |
| 94 | +Let <tt><i>final-sndr</i></tt> be the expression <tt><i>transformed-sndr</i></tt> if |
| 95 | +<tt><i>transformed-sndr</i></tt> and <tt><i>sndr</i></tt> have the same <ins>decayed</ins> |
| 96 | +type <del>ignoring cv-qualifiers</del>; otherwise, it is the expression |
| 97 | +<tt>transform_sender(dom, <i>transformed-sndr</i>, env...)</tt>. |
| 98 | +</p> |
| 99 | +</blockquote> |
| 100 | +</blockquote> |
| 101 | + |
| 102 | +</li> |
| 103 | + |
| 104 | +</ol> |
| 105 | +</resolution> |
| 106 | + |
| 107 | +</issue> |
0 commit comments