Skip to content

Commit 9edb9f8

Browse files
author
github-actions
committed
Automatic update from GitHub Actions workflow
1 parent 9cb8bf0 commit 9edb9f8

22 files changed

+460
-41
lines changed

issue4230.html

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Issue 4230: simd&lt;complex&gt;::real/imag is overconstrained</title>
6+
<meta property="og:title" content="Issue 4230: simd&lt;complex&gt;::real/imag is overconstrained">
7+
<meta property="og:description" content="C++ library issue. Status: New">
8+
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4230.html">
9+
<meta property="og:type" content="website">
10+
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
11+
<meta property="og:image:alt" content="C++ logo">
12+
<style>
13+
p {text-align:justify}
14+
li {text-align:justify}
15+
pre code.backtick::before { content: "`" }
16+
pre code.backtick::after { content: "`" }
17+
blockquote.note
18+
{
19+
background-color:#E0E0E0;
20+
padding-left: 15px;
21+
padding-right: 15px;
22+
padding-top: 1px;
23+
padding-bottom: 1px;
24+
}
25+
ins {background-color:#A0FFA0}
26+
del {background-color:#FFA0A0}
27+
table.issues-index { border: 1px solid; border-collapse: collapse; }
28+
table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
29+
table.issues-index td { padding: 4px; border: 1px solid; }
30+
table.issues-index td:nth-child(1) { text-align: right; }
31+
table.issues-index td:nth-child(2) { text-align: left; }
32+
table.issues-index td:nth-child(3) { text-align: left; }
33+
table.issues-index td:nth-child(4) { text-align: left; }
34+
table.issues-index td:nth-child(5) { text-align: center; }
35+
table.issues-index td:nth-child(6) { text-align: center; }
36+
table.issues-index td:nth-child(7) { text-align: left; }
37+
table.issues-index td:nth-child(5) span.no-pr { color: red; }
38+
@media (prefers-color-scheme: dark) {
39+
html {
40+
color: #ddd;
41+
background-color: black;
42+
}
43+
ins {
44+
background-color: #225522
45+
}
46+
del {
47+
background-color: #662222
48+
}
49+
a {
50+
color: #6af
51+
}
52+
a:visited {
53+
color: #6af
54+
}
55+
blockquote.note
56+
{
57+
background-color: rgba(255, 255, 255, .10)
58+
}
59+
}
60+
</style>
61+
</head>
62+
<body>
63+
<hr>
64+
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p>
65+
<h3 id="4230"><a href="lwg-active.html#4230">4230</a>. <code>simd&lt;complex&gt;::real/imag</code> is overconstrained</h3>
66+
<p><b>Section:</b> 99 [simd.complex.access] <b>Status:</b> <a href="lwg-active.html#New">New</a>
67+
<b>Submitter:</b> Matthias Kretz <b>Opened:</b> 2025-03-18 <b>Last modified:</b> 2025-03-22</p>
68+
<p><b>Priority: </b>Not Prioritized
69+
</p>
70+
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
71+
<p><b>Discussion:</b></p>
72+
<p>
73+
99 [simd.complex.access] overconstrains the arguments to <code class='backtick'>real</code> and <code class='backtick'>imag</code>.
74+
<code>complex&lt;T&gt;::real/imag</code> allows conversions to <code class='backtick'>T</code> whereas <code>simd&lt;complex&lt;T&gt;&gt;</code>
75+
requires basically an exact match (<code>same_as&lt;simd&lt;T&gt;&gt;</code> modulo ABI tag differences).
76+
</p>
77+
<blockquote><pre>
78+
complex&lt;double&gt; c = {};
79+
c.real(1.f); // OK
80+
81+
simd&lt;complex&lt;double&gt;&gt; sc = {};
82+
sc.real(simd&lt;float&gt;(1.f)); // <span style="color:red;font-weight:bolder">ill-formed, should be allowed</span>
83+
</pre></blockquote>
84+
<p>
85+
The design intent was to match the <code>std::complex&lt;T&gt;</code> interface. In which case
86+
the current wording doesn't match that intent. <code class='backtick'>complex</code> doesn't say <code>real(same_as&lt;T&gt; auto)</code>
87+
but 'real(T)', which allows conversions.
88+
</p>
89+
90+
91+
<p id="res-4230"><b>Proposed resolution:</b></p>
92+
<p>
93+
This wording is relative to <a href="https://wg21.link/N5008">N5008</a>.
94+
</p>
95+
96+
<ol>
97+
98+
<li><p>Modify 29.10.6.1 <a href="https://wg21.link/simd.overview">[simd.overview]</a>, class template <code class='backtick'>basic_simd</code> synopsis, as indicated:</p>
99+
100+
<blockquote>
101+
<pre>
102+
[&hellip;]
103+
<i>// 99 [simd.complex.access], basic_simd complex-value accessors</i>
104+
constexpr auto real() const noexcept;
105+
constexpr auto imag() const noexcept;
106+
<del>template&lt;<i>simd-floating-point</i> V&gt;</del>
107+
constexpr void real(<ins><i>see below</i></ins><del>const V&amp;</del> v) noexcept;
108+
<del>template&lt;<i>simd-floating-point</i> V&gt;</del>
109+
constexpr void imag(<ins><i>see below</i></ins><del>const V&amp;</del> v) noexcept;
110+
[&hellip;]
111+
</pre>
112+
</blockquote>
113+
</li>
114+
115+
<li><p>Modify 99 [simd.complex.access] as indicated:</p>
116+
117+
<blockquote>
118+
<pre>
119+
<del>template&lt;<i>simd-floating-point</i> V&gt;</del>
120+
constexpr void real(<ins><i>see below</i></ins><del>const V&amp;</del> v) noexcept;
121+
<del>template&lt;<i>simd-floating-point</i> V&gt;</del>
122+
constexpr void imag(<ins><i>see below</i></ins><del>const V&amp;</del> v) noexcept;
123+
</pre>
124+
<blockquote>
125+
<p>
126+
-3- <i>Constraints</i>:
127+
</p>
128+
<ol style="list-style-type: none">
129+
<li><p><del>(3.1) &mdash;</del> <code><i>simd-complex</i>&lt;basic_simd&gt;</code> is modeled<ins>.</ins><del>,</del></p></li>
130+
<li><p><del>(3.2) &mdash; <code>same_as&lt;typename V::value_type, typename T::value_type&gt;</code> is modeled, and</del></p></li>
131+
<li><p><del>(3.3) &mdash; <code class='backtick'>V::size() == size()</code> is <code class='backtick'>true</code>.</del></p></li>
132+
</ol>
133+
<p>
134+
-4- <i>Effects</i>: Replaces each element of the <code class='backtick'>basic_simd</code> object such that the <code><i>i</i></code><sup>th</sup>
135+
element is replaced with <code>value_type(v[<i>i</i>], operator[](<i>i</i>).imag())</code> or
136+
<code>value_type(operator[](<i>i</i>).real(), v[<i>i</i>])</code> for <code class='backtick'>real</code> and <code class='backtick'>imag</code> respectively,
137+
for all <code><i>i</i></code> in the range <code class='backtick'>[0, size())</code>.
138+
<p/>
139+
<ins>-?- <i>Remarks</i>: The type of argument <code class='backtick'>v</code> is
140+
<code>const rebind_t&lt;typename T::value_type, basic_simd&lt;T, Abi&gt;&gt;&amp;</code>.</ins>
141+
</p>
142+
</blockquote>
143+
</blockquote>
144+
</li>
145+
146+
</ol>
147+
148+
149+
150+
151+
152+
</body>
153+
</html>

0 commit comments

Comments
 (0)