|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4369" status="New"> |
| 5 | +<title><tt><i>check-types</i></tt> function for `upon_error` and `upon_stopped` is wrong</title> |
| 6 | +<section> |
| 7 | +<sref ref="[exec.then]"/> |
| 8 | +</section> |
| 9 | +<submitter>Eric Niebler</submitter> |
| 10 | +<date>31 Aug 2025</date> |
| 11 | +<priority>99</priority> |
| 12 | + |
| 13 | +<discussion> |
| 14 | +<p> |
| 15 | +The following has been reported by Trevor Gray: |
| 16 | +</p> |
| 17 | +<p> |
| 18 | +In <sref ref="[exec.then]"/> p5, the <tt><i>impls-for</i><<i>decayed-typeof</i><<i>then-cpo</i>>>::<i>check-types</i></tt> |
| 19 | +unction is specified as follows: |
| 20 | +</p> |
| 21 | +<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;"> |
| 22 | +<pre> |
| 23 | +template<class Sndr, class... Env> |
| 24 | + static consteval void <i>check-types</i>(); |
| 25 | +</pre> |
| 26 | +<blockquote> |
| 27 | +<p> |
| 28 | +<i>Effects</i>: Equivalent to: |
| 29 | +</p> |
| 30 | +<blockquote><pre> |
| 31 | +auto cs = get_completion_signatures<<i>child-type</i><Sndr>, <i>FWD-ENV-T</i>(Env)...>(); |
| 32 | +auto fn = []<class... Ts>(set_value_t(*)(Ts...)) { |
| 33 | + if constexpr (!invocable<remove_cvref_t<<i>data-type</i><Sndr>>, Ts...>) |
| 34 | + throw <i>unspecified-exception</i>(); |
| 35 | +}; |
| 36 | +cs.<i>for-each</i>(<i>overload-set</i>{fn, [](auto){}}); |
| 37 | +</pre></blockquote> |
| 38 | +<p> |
| 39 | +where <tt><i>unspecified-exception</i></tt> is a type derived from `exception`. |
| 40 | +</p> |
| 41 | +</blockquote> |
| 42 | +</blockquote> |
| 43 | +<p> |
| 44 | +The line <tt>auto fn = []<class... Ts>(set_value_t(*)(Ts...)) {</tt> |
| 45 | +is correct when <tt><i>then-cpo</i></tt> is `then` but not when it is `upon_error` or `upon_stopped`. |
| 46 | +<p/> |
| 47 | +For `upon_error` it should be: |
| 48 | +</p> |
| 49 | +<blockquote><pre> |
| 50 | +auto fn = []<class... Ts>(set_error_t(*)(Ts...)) { |
| 51 | +</pre></blockquote> |
| 52 | +<p> |
| 53 | +and for `upon_stopped` it should be: |
| 54 | +</p> |
| 55 | +<blockquote><pre> |
| 56 | +auto fn = []<class... Ts>(set_stopped_t(*)(Ts...)) { |
| 57 | +</pre></blockquote> |
| 58 | +<p> |
| 59 | +We can achieve that by replacing `set_value_t` in the problematic line with <tt><i>decayed-typeof</i><<i>set-cpo</i>></tt>. |
| 60 | +</p> |
| 61 | +</discussion> |
| 62 | + |
| 63 | +<resolution> |
| 64 | +<p> |
| 65 | +This wording is relative to <paper num="N5014"/>. |
| 66 | +</p> |
| 67 | + |
| 68 | +<ol> |
| 69 | + |
| 70 | +<li><p>Modify <sref ref="[exec.then]"/> as indicated:</p> |
| 71 | + |
| 72 | +<blockquote> |
| 73 | +<pre> |
| 74 | +template<class Sndr, class... Env> |
| 75 | + static consteval void <i>check-types</i>(); |
| 76 | +</pre> |
| 77 | +<blockquote> |
| 78 | +<p> |
| 79 | +-5- <i>Effects:</i> Equivalent to: |
| 80 | +</p> |
| 81 | +<blockquote><pre> |
| 82 | +auto cs = get_completion_signatures<<i>child-type</i><Sndr>, <i>FWD-ENV-T</i>(Env)...>(); |
| 83 | +auto fn = []<class... Ts>(<del>set_value_t</del><ins><i>decayed-typeof</i><<i>set-cpo</i>></ins>(*)(Ts...)) { |
| 84 | + if constexpr (!invocable<remove_cvref_t<<i>data-type</i><Sndr>>, Ts...>) |
| 85 | + throw <i>unspecified-exception</i>(); |
| 86 | +}; |
| 87 | +cs.<i>for-each</i>(<i>overload-set</i>{fn, [](auto){}}); |
| 88 | +</pre></blockquote> |
| 89 | +<p> |
| 90 | +where <tt><i>unspecified-exception</i></tt> is a type derived from `exception`. |
| 91 | +</p> |
| 92 | +</blockquote> |
| 93 | +</blockquote> |
| 94 | + |
| 95 | +</li> |
| 96 | + |
| 97 | +</ol></resolution> |
| 98 | + |
| 99 | +</issue> |
0 commit comments