Skip to content

Commit b15e7a8

Browse files
committed
New P/R for 4460
1 parent 1aac0c5 commit b15e7a8

File tree

1 file changed

+218
-2
lines changed

1 file changed

+218
-2
lines changed

xml/issue4460.xml

Lines changed: 218 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,55 @@ Note how in R0 neither one of the `emplaced_type_t`/`emplaced_index_t`
2323
(as they were then called) + `initializer_list` constructors have a
2424
throws clause. In R1 only one of them gained it."
2525
</blockquote>
26+
<superseded>
27+
<p>
28+
This wording is relative to <paper num="N5014"/>.
29+
</p>
30+
31+
<ol>
32+
<li><p>Modify <sref ref="[variant.ctor]"/>, as indicated:</p>
33+
34+
<blockquote>
35+
<pre>
36+
template&lt;size_t I, class U, class... Args&gt;
37+
constexpr explicit variant(in_place_index_t&lt;I&gt;, initializer_list&lt;U&gt; il, Args&amp;&amp;... args);
38+
</pre>
39+
<blockquote>
40+
<p>-35- <i>Constraints</i>:
41+
<ol style="list-style-type: none">
42+
<li>(35.1) &mdash; `I` is less than `sizeof...(Types)` and</li>
43+
<li>(35.2) &mdash;
44+
<code>is_constructible_v&lt;T<sub>I</sub>, initializer_list&lt;U&gt;&amp;, Args...&gt;</code>
45+
is `true`.
46+
</li>
47+
</ol>
48+
</p>
49+
<p>-36- <i>Effects</i>:
50+
Direct-non-list-initializes the contained value of type
51+
<tt>T<sub>I</sub></tt> with <code>il, std::forward&lt;Args&gt;(args)...</code>.
52+
</p>
53+
<p>-37- <i>Postconditions</i>: `index()` is `I`.</p>
54+
<p><ins>-?- <i>Throws</i>:
55+
Any exception thrown by calling the selected constructor of
56+
<tt>T<sub>I</sub></tt>.
57+
</ins>
58+
</p>
59+
<p>-38- <i>Remarks</i>:
60+
If <tt>T<sub>I</sub></tt>’s selected constructor is a constexpr constructor,
61+
this constructor is a constexpr constructor.
62+
</p>
63+
</blockquote>
64+
</blockquote>
65+
</li>
66+
</ol>
67+
</superseded>
68+
69+
<note>2025-11-11; Jonathan provides improved wording</note>
70+
2671
</discussion>
2772

2873
<resolution>
74+
2975
<p>
3076
This wording is relative to <paper num="N5014"/>.
3177
</p>
@@ -34,6 +80,176 @@ This wording is relative to <paper num="N5014"/>.
3480
<li><p>Modify <sref ref="[variant.ctor]"/>, as indicated:</p>
3581

3682
<blockquote>
83+
<pre>
84+
constexpr variant() noexcept(<i>see below</i>);
85+
</pre>
86+
<blockquote>
87+
<p>-2- <i>Constraints</i>:
88+
<code>is_default_constructible_v&lt;T<sub>0</sub>&gt;</code> is `true`.
89+
</p>
90+
<p>-3- <i>Effects</i>:
91+
Constructs a `variant` holding a value-initialized value of type <tt>T<sub>0</sub></tt>.
92+
</p>
93+
<p>-4- <i>Postconditions</i>:
94+
`valueless_by_exception()` is `false` and `index()` is `0`.
95+
</p>
96+
<p>-5- <i>Throws</i>:
97+
Any exception thrown by the value-initialization of <tt>T<sub>0</sub></tt>.
98+
</p>
99+
<p>-6- <i>Remarks</i>: [&hellip;]
100+
</p>
101+
</blockquote>
102+
103+
<pre>
104+
constexpr variant(const variant&amp;);
105+
</pre>
106+
<blockquote>
107+
<p>-7- <i>Effects</i>:
108+
If `w` holds a value, initializes the `variant` to hold the same alternative
109+
as `w` and direct-initializes the contained value with
110+
<code><i>GET</i>&lt;j&gt;(w)</code>, where `j` is `w.index()`.
111+
Otherwise, initializes the `variant` to not hold a value.
112+
</p>
113+
<p>-8- <i>Throws</i>:
114+
Any exception thrown by
115+
<del>direct-initializating any <tt>T<sub>i</sub></tt> for all <i>i</i></del>
116+
<ins>the initialization of the contained value</ins>.
117+
</p>
118+
<p>-9- <i>Remarks</i>: [&hellip;]
119+
</p>
120+
</blockquote>
121+
122+
<pre>
123+
constexpr variant(variant&amp;&amp;) noexcept(<i>see below</i>);
124+
</pre>
125+
<blockquote>
126+
<p>-10- <i>Constraints</i>:
127+
<code>is_move_constructible_v&lt;T<sub>i</sub>&gt;</code> is `true`
128+
for all <i>i</i>.
129+
</p>
130+
<p>-11- <i>Effects</i>:
131+
If `w` holds a value, initializes the `variant` to hold the same alternative
132+
as `w` and direct-initializes the contained value with
133+
<code><i>GET</i>&lt;j&gt;(std::move(w))</code>, where `j` is `w.index()`.
134+
Otherwise, initializes the `variant` to not hold a value.
135+
</p>
136+
<p>-12- <i>Throws</i>:
137+
Any exception thrown by
138+
<del>move-constructing any <tt>T<sub>i</sub></tt> for all <i>i</i></del>
139+
<ins>the initialization of the contained value</ins>.
140+
</p>
141+
<p>-13- <i>Remarks</i>: [&hellip;]
142+
</p>
143+
</blockquote>
144+
145+
<pre>
146+
template&lt;class T&gt; constexpr variant(T&amp;&amp;) noexcept(<i>see below</i>);
147+
</pre>
148+
<blockquote>
149+
<p>-14-
150+
Let <tt>T<sub>j</sub></tt> be a type that is determined as follows:
151+
build an imaginary function <tt><i>FUN</i>(T<sub>i</sub>)</tt>
152+
for each alternative type <tt>T<sub>i</sub></tt>
153+
for which <tt>T<sub>i</sub> x[] = {std::forward&lt;T&gt;(t)};</tt>
154+
is well-formed for some invented variable `x`.
155+
The overload <tt><i>FUN</i>(T<sub>j</sub>)</tt> selected by overload resolution
156+
for the expression <tt><i>FUN</i>(std::forward&lt;T&gt;(t))</tt> defines
157+
the alternative <tt>T<sub>j</sub></tt> which is the type
158+
of the contained value after construction.
159+
</p>
160+
<p>-15- <i>Constraints</i>: [&hellip;]
161+
</p>
162+
<p>-16- <i>Effects</i>:
163+
Initializes `*this` to hold the alternative type <tt>T<sub>j</sub></tt>
164+
and direct-non-list-initializes the contained value with
165+
<code>std::forward&lt;T&gt;(t)</code>.
166+
</p>
167+
<p>-17- <i>Postconditions</i>: [&hellip;]
168+
</p>
169+
<p>-18- <i>Throws</i>:
170+
Any exception thrown by the initialization of the
171+
<del>selected alternative <tt>T<sub>j</sub></tt></del>
172+
<ins>contained value</ins>.
173+
</p>
174+
<p>-19- <i>Remarks</i>: [&hellip;]
175+
</p>
176+
</blockquote>
177+
178+
<pre>
179+
template&lt;class T, class... Args&gt; constexpr variant(in_place_type_t&lt;T&gt;, Args&amp;&amp;... args);
180+
</pre>
181+
<blockquote>
182+
<p>-20- <i>Constraints</i>: [&hellip;]
183+
</p>
184+
<p>-21- <i>Effects</i>:
185+
Direct-non-list-initializes the contained value of type `T`
186+
with
187+
<code>std::forward&lt;Args&gt;(args)...</code>.
188+
</p>
189+
<p>-22- <i>Postconditions</i>: [&hellip;]
190+
</p>
191+
<p>-23- <i>Throws</i>:
192+
Any exception thrown by
193+
<del>the selected constructor of `T`</del>
194+
<ins>the initialization of the contained value</ins>.
195+
</p>
196+
<p>-24- <i>Remarks</i>: [&hellip;]
197+
</p>
198+
</blockquote>
199+
200+
<pre>
201+
template&lt;class T, class U, class... Args&gt;
202+
constexpr variant(in_place_type_t&lt;T&gt;, initializer_list&lt;U&gt; li, Args&amp;&amp;... args);
203+
</pre>
204+
<blockquote>
205+
<p>-25- <i>Constraints</i>: [&hellip;]
206+
</p>
207+
<p>-26- <i>Effects</i>:
208+
Direct-non-list-initializes the contained value of type `T`
209+
with
210+
<code>il, std::forward&lt;Args&gt;(args)...</code>.
211+
</p>
212+
<p>-27- <i>Postconditions</i>: [&hellip;]
213+
</p>
214+
<p>-28- <i>Throws</i>:
215+
Any exception thrown by
216+
<del>the selected constructor of `T`</del>
217+
<ins>the initialization of the contained value</ins>.
218+
</p>
219+
<p>-29- <i>Remarks</i>: [&hellip;]
220+
</p>
221+
</blockquote>
222+
223+
<pre>
224+
template&lt;size_t I, class... Args&gt;
225+
constexpr explicit variant(in_place_index_t&lt;I&gt;, Args&amp;&amp;... args);
226+
</pre>
227+
<blockquote>
228+
<p>-30- <i>Constraints</i>:
229+
<ol style="list-style-type: none">
230+
<li>(30.1) &mdash; `I` is less than `sizeof...(Types)` and</li>
231+
<li>(30.2) &mdash;
232+
<code>is_constructible_v&lt;T<sub>I</sub>, Args...&gt;</code>
233+
is `true`.
234+
</li>
235+
</ol>
236+
</p>
237+
<p>-31- <i>Effects</i>:
238+
Direct-non-list-initializes the contained value of type
239+
<tt>T<sub>I</sub></tt> with <code>std::forward&lt;Args&gt;(args)...</code>.
240+
</p>
241+
<p>-32- <i>Postconditions</i>: `index()` is `I`.</p>
242+
<p>-33- <i>Throws</i>:
243+
Any exception thrown by
244+
<del>the selected constructor of <tt>T<sub>i</sub></tt></del>
245+
<ins>the initialization of the contained value</ins>.
246+
</p>
247+
<p>-34- <i>Remarks</i>:
248+
If <tt>T<sub>I</sub></tt>’s selected constructor is a constexpr constructor,
249+
this constructor is a constexpr constructor.
250+
</p>
251+
</blockquote>
252+
37253
<pre>
38254
template&lt;size_t I, class U, class... Args&gt;
39255
constexpr explicit variant(in_place_index_t&lt;I&gt;, initializer_list&lt;U&gt; il, Args&amp;&amp;... args);
@@ -54,8 +270,7 @@ Direct-non-list-initializes the contained value of type
54270
</p>
55271
<p>-37- <i>Postconditions</i>: `index()` is `I`.</p>
56272
<p><ins>-?- <i>Throws</i>:
57-
Any exception thrown by calling the selected constructor of
58-
<tt>T<sub>I</sub></tt>.
273+
Any exception thrown by the initialization of the contained value.
59274
</ins>
60275
</p>
61276
<p>-38- <i>Remarks</i>:
@@ -66,6 +281,7 @@ this constructor is a constexpr constructor.
66281
</blockquote>
67282
</li>
68283
</ol>
284+
69285
</resolution>
70286

71287
</issue>

0 commit comments

Comments
 (0)