Skip to content

Commit 3dbd870

Browse files
committed
New issue from Hewill: "std::simd::select(bool c, const T& a, const U& b) is underconstrained "
1 parent 3897bea commit 3dbd870

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

xml/issue4386.xml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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&amp; a, const U&amp; 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+
[&hellip;]
38+
// <i><sref ref="[simd.alg]"/>, algorithms</i>
39+
[&hellip;]
40+
template&lt;<ins>copyable</ins><del>class</del> T, <ins>copyable</ins><del>class</del> U&gt;
41+
constexpr auto select(bool c, const T&amp; a, const U&amp; b)
42+
-&gt; remove_cvref_t&lt;decltype(c ? a : b)&gt;;
43+
[&hellip;]
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&lt;<ins>copyable</ins><del>class</del> T, <ins>copyable</ins><del>class</del> U&gt;
55+
constexpr auto select(bool c, const T&amp; a, const U&amp; b)
56+
-&gt; remove_cvref_t&lt;decltype(c ? a : b)&gt;;
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

Comments
 (0)