Skip to content

Commit db48097

Browse files
committed
Update PR for 4383.
1 parent 02ef747 commit db48097

File tree

1 file changed

+87
-15
lines changed

1 file changed

+87
-15
lines changed

xml/issue4383.xml

Lines changed: 87 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,61 +77,61 @@ struct <i>cw-operators</i> {
7777
// <i>pseudo-mutators</i>
7878
template&lt;<i>constexpr-param</i> T&gt;
7979
constexpr auto operator++(this T) noexcept
80-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>++x<ins>&gt;()</ins>; }
80+
requires requires(T::value_type x) { constant_wrapper&lt;++x&gt;(); }
8181
{ return constant_wrapper&lt;[] { auto c = T::value; return ++c; }()&gt;{}; }
8282
template&lt;<i>constexpr-param</i> T&gt;
8383
constexpr auto operator++(this T, int) noexcept
84-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x++<ins>&gt;()</ins>; }
84+
requires requires(T::value_type x) { constant_wrapper&lt;x++&gt;(); }
8585
{ return constant_wrapper&lt;[] { auto c = T::value; return c++; }()&gt;{}; }
8686

8787
template&lt;<i>constexpr-param</i> T&gt;
8888
constexpr auto operator--(this T) noexcept
89-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>--x<ins>&gt;()</ins>; }
89+
requires requires(T::value_type x) { constant_wrapper&lt;--x&gt;(); }
9090
{ return constant_wrapper&lt;[] { auto c = T::value; return --c; }()&gt;{}; }
9191
template&lt;<i>constexpr-param</i> T&gt;
9292
constexpr auto operator--(this T, int) noexcept
93-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x--<ins>&gt;()</ins>; }
93+
requires requires(T::value_type x) { constant_wrapper&lt;x--&gt;(); }
9494
{ return constant_wrapper&lt;[] { auto c = T::value; return c--; }()&gt;{}; }
9595

9696
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
9797
constexpr auto operator+=(this T, R) noexcept
98-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x += R::value<ins>&gt;()</ins>; }
98+
requires requires(T::value_type x) { constant_wrapper&lt;x += R::value&gt;(); }
9999
{ return constant_wrapper&lt;[] { auto v = T::value; return v += R::value; }()&gt;{}; }
100100
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
101101
constexpr auto operator-=(this T, R) noexcept
102-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x -= R::value<ins>&gt;()</ins>; }
102+
requires requires(T::value_type x) { constant_wrapper&lt;x -= R::value&gt;(); }
103103
{ return constant_wrapper&lt;[] { auto v = T::value; return v -= R::value; }()&gt;{}; }
104104
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
105105
constexpr auto operator*=(this T, R) noexcept
106-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x *= R::value<ins>&gt;()</ins>; }
106+
requires requires(T::value_type x) { constant_wrapper&lt;x *= R::value&gt;(); }
107107
{ return constant_wrapper&lt;[] { auto v = T::value; return v *= R::value; }()&gt;{}; }
108108
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
109109
constexpr auto operator/=(this T, R) noexcept
110-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x /= R::value<ins>&gt;()</ins>; }
110+
requires requires(T::value_type x) { constant_wrapper&lt;x /= R::value&gt;(); }
111111
{ return constant_wrapper&lt;[] { auto v = T::value; return v /= R::value; }()&gt;{}; }
112112
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
113113
constexpr auto operator%=(this T, R) noexcept
114-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x %= R::value<ins>&gt;()</ins>; }
114+
requires requires(T::value_type x) { constant_wrapper&lt;x %= R::value&gt;(); }
115115
{ return constant_wrapper&lt;[] { auto v = T::value; return v %= R::value; }()&gt;{}; }
116116
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
117117
constexpr auto operator&amp;=(this T, R) noexcept
118-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x &amp;= R::value<ins>&gt;()</ins>; }
118+
requires requires(T::value_type x) { constant_wrapper&lt;x &amp;= R::value&gt;(); }
119119
{ return constant_wrapper&lt;[] { auto v = T::value; return v &amp;= R::value; }()&gt;{}; }
120120
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
121121
constexpr auto operator|=(this T, R) noexcept
122-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x |= R::value<ins>&gt;()</ins>; }
122+
requires requires(T::value_type x) { constant_wrapper&lt;x |= R::value&gt;(); }
123123
{ return constant_wrapper&lt;[] { auto v = T::value; return v |= R::value; }()&gt;{}; }
124124
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
125125
constexpr auto operator^=(this T, R) noexcept
126-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x ^= R::value<ins>&gt;()</ins>; }
126+
requires requires(T::value_type x) { constant_wrapper&lt;x ^= R::value&gt;(); }
127127
{ return constant_wrapper&lt;[] { auto v = T::value; return v ^= R::value; }()&gt;{}; }
128128
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
129129
constexpr auto operator&lt;&lt;=(this T, R) noexcept
130-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x &lt;&lt;= R::value<ins>&gt;()</ins>; }
130+
requires requires(T::value_type x) { constant_wrapper&lt;x &lt;&lt;= R::value&gt;(); }
131131
{ return constant_wrapper&lt;[] { auto v = T::value; return v &lt;&lt;= R::value; }()&gt;{}; }
132132
template&lt;<i>constexpr-param</i> T, <i>constexpr-param</i> R&gt;
133133
constexpr auto operator&gt;&gt;=(this T, R) noexcept
134-
requires requires(T::value_type x) { <ins>constant_wrapper&lt;</ins>x &gt;&gt;= R::value<ins>&gt;()</ins>; }
134+
requires requires(T::value_type x) { constant_wrapper&lt;x &gt;&gt;= R::value&gt;(); }
135135
{ return constant_wrapper&lt;[] { auto v = T::value; return v &gt;&gt;= R::value; }()&gt;{}; }
136136
};
137137
</pre>
@@ -142,7 +142,79 @@ struct <i>cw-operators</i> {
142142
</ol>
143143
</superseded>
144144

145-
<note>2025-11-04; Zach provides improved wording</note>
145+
<p>
146+
This wording is relative to <paper num="N5014"/>.
147+
</p>
148+
149+
<ol>
150+
151+
<li><p>Modify <sref ref="[const.wrap.class]"/>, class template <tt>constant_wrapper</tt> synopsis, as indicated:</p>
152+
153+
<blockquote class="note">
154+
<p>
155+
[<i>Drafting note:</i> The requires clause follows the form of `constant_wrapper`'s
156+
function call operator.]
157+
</p>
158+
</blockquote>
159+
160+
<blockquote>
161+
<pre>
162+
struct <i>cw-operators</i> { // <i>exposition only</i>
163+
[&hellip;]
164+
// <i>pseudo-mutators</i>
165+
template&lt;<i>constexpr-param</i> T&gt;
166+
constexpr auto operator++(this T) noexcept -&gt; constant_wrapper&lt;++Y&gt; { return {}; }
167+
template&lt;<i>constexpr-param</i> T&gt;
168+
constexpr auto operator++(this T, int) noexcept -&gt; constant_wrapper&lt;Y++&gt; { return {}; }
169+
template&lt;<i>constexpr-param</i> T&gt;
170+
constexpr auto operator--(this T) noexcept -&gt; constant_wrapper&lt;--Y&gt; { return {}; }
171+
template&lt;<i>constexpr-param</i> T&gt;
172+
constexpr auto operator--(this T, int) noexcept -&gt; constant_wrapper&lt;Y--&gt; { return {}; }
173+
174+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
175+
friend constexpr auto operator+=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value += V::value)&gt; { return {}; }
176+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
177+
friend constexpr auto operator-=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value -= V::value)&gt; { return {}; }
178+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
179+
friend constexpr auto operator*=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value *= V::value)&gt; { return {}; }
180+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
181+
friend constexpr auto operator/=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value /= V::value)&gt; { return {}; }
182+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
183+
friend constexpr auto operator%=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value %= V::value)&gt; { return {}; }
184+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
185+
friend constexpr auto operator&amp;=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value &amp;= V::value)&gt; { return {}; }
186+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
187+
friend constexpr auto operator|=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value |= V::value)&gt; { return {}; }
188+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
189+
friend constexpr auto operator^=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value ^= V::value)&gt; { return {}; }
190+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
191+
friend constexpr auto operator&lt;&lt;=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value &lt;&lt;= V::value)&gt; { return {}; }
192+
template&lt;<i>constexpr-param</i> U, <i>constexpr-param</i> V&gt;
193+
friend constexpr auto operator&gt;&gt;=(U, V) noexcept -&gt; constant_wrapper&lt;(U::value &gt;&gt;= V::value)&gt; { return {}; }
194+
};
195+
}
196+
197+
template&lt;exposition_only::cw_fixed_value X, typename&gt;
198+
struct constant_wrapper: exposition_only::cw_operators {
199+
static constexpr const auto &amp; value = X.data;
200+
using type = constant_wrapper;
201+
using value_type = typename decltype(X)::type;
202+
203+
<del>template&lt;<i>constexpr-param</i> R&gt;
204+
constexpr auto operator=(R) const noexcept requires requires(value_type x) { x = R::value; }
205+
{ return constant_wrapper&lt;[] { auto v = value; return v = R::value; }()&gt;{}; }</del>
206+
<ins>template&lt;<i>constexpr-param</i> R&gt;
207+
constexpr auto operator=(R) const noexcept -&gt; constant_wrapper&lt;X = R::value&gt; { return {}; }</ins>
208+
209+
constexpr operator decltype(auto)() const noexcept { return value; }
210+
};
211+
212+
</pre>
213+
</blockquote>
214+
215+
</li>
216+
217+
</ol>
146218

147219
</discussion>
148220

0 commit comments

Comments
 (0)