|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4386" status="New"> |
| 5 | +<title><code>std::simd::select(bool c, const T& a, const U& b)</code> is underconstrained |
| 6 | +</title> |
| 7 | +<section> |
| 8 | +<sref ref="[simd.alg]"/> |
| 9 | +</section> |
| 10 | +<submitter>Hewill Kang</submitter> |
| 11 | +<date>27 Sep 2025</date> |
| 12 | +<priority>99</priority> |
| 13 | + |
| 14 | +<discussion> |
| 15 | +<p> |
| 16 | +This function currently only requires that `c ? a : b` be a well-formed expression, which simply |
| 17 | +returns `c ? a : b`. |
| 18 | +<p/> |
| 19 | +Given that it seems intended to work with `basic_vec`, `basic_mask`, or vectorizable type, |
| 20 | +requiring `T` and `U` to be copyable seems reasonable since they are trivially copyable. |
| 21 | +It shouldn't take non-copyable objects and produce hard errors in the function body. |
| 22 | +</p> |
| 23 | +</discussion> |
| 24 | + |
| 25 | +<resolution> |
| 26 | +<p> |
| 27 | +This wording is relative to <paper num="N5014"/>. |
| 28 | +</p> |
| 29 | + |
| 30 | +<ol> |
| 31 | + |
| 32 | +<li><p>Modify <sref ref="[simd.syn]"/> as indicated:</p> |
| 33 | + |
| 34 | +<blockquote> |
| 35 | +<pre> |
| 36 | +namespace std::simd { |
| 37 | + […] |
| 38 | + // <i><sref ref="[simd.alg]"/>, algorithms</i> |
| 39 | + […] |
| 40 | + template<<ins>copyable</ins><del>class</del> T, <ins>copyable</ins><del>class</del> U> |
| 41 | + constexpr auto select(bool c, const T& a, const U& b) |
| 42 | + -> remove_cvref_t<decltype(c ? a : b)>; |
| 43 | + […] |
| 44 | +}; |
| 45 | +</pre> |
| 46 | +</blockquote> |
| 47 | + |
| 48 | +</li> |
| 49 | + |
| 50 | +<li><p>Modify <sref ref="[simd.alg]"/> as indicated:</p> |
| 51 | + |
| 52 | +<blockquote> |
| 53 | +<pre> |
| 54 | +template<<ins>copyable</ins><del>class</del> T, <ins>copyable</ins><del>class</del> U> |
| 55 | + constexpr auto select(bool c, const T& a, const U& b) |
| 56 | + -> remove_cvref_t<decltype(c ? a : b)>; |
| 57 | +</pre> |
| 58 | +<blockquote> |
| 59 | +<p> |
| 60 | +-9- <i>Effects</i>: Equivalent to: <code>return c ? a : b;</code> |
| 61 | +</p> |
| 62 | +</blockquote> |
| 63 | +</blockquote> |
| 64 | + |
| 65 | +</li> |
| 66 | + |
| 67 | +</ol> |
| 68 | +</resolution> |
| 69 | + |
| 70 | +</issue> |
0 commit comments