|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4460" status="New"> |
| 5 | +<title>Missing <i>Throws</i>: for last `variant` constructor</title> |
| 6 | +<section><sref ref="[variant.ctor]"/></section> |
| 7 | +<submitter>Jonathan Wakely</submitter> |
| 8 | +<date>07 Nov 2025</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<p> |
| 13 | +All `variant` constructors except the last one have a <i>Throws</i>: element |
| 14 | +saying what they're allowed to throw. |
| 15 | +</p> |
| 16 | +<p> |
| 17 | +This originates from an editorial pull request, where the submitter said: |
| 18 | +</p> |
| 19 | +<blockquote> |
| 20 | +"It looks like this defect is an artifact of a change between |
| 21 | +<paper num="P0088R0"/> and <paper num="P0088R1"/>. |
| 22 | +Note how in R0 neither one of the `emplaced_type_t`/`emplaced_index_t` |
| 23 | +(as they were then called) + `initializer_list` constructors have a |
| 24 | +throws clause. In R1 only one of them gained it." |
| 25 | +</blockquote> |
| 26 | +</discussion> |
| 27 | + |
| 28 | +<resolution> |
| 29 | +<p> |
| 30 | +This wording is relative to <paper num="N5014"/>. |
| 31 | +</p> |
| 32 | + |
| 33 | +<ol> |
| 34 | +<li><p>Modify <sref ref="[variant.ctor]"/>, as indicated:</p> |
| 35 | + |
| 36 | +<blockquote> |
| 37 | +<pre> |
| 38 | +template<size_t I, class U, class... Args> |
| 39 | + constexpr explicit variant(in_place_index_t<I>, initializer_list<U> il, Args&&... args); |
| 40 | +</pre> |
| 41 | +<blockquote> |
| 42 | +<p>-35- <i>Constraints</i>: |
| 43 | +<ol style="list-style-type: none"> |
| 44 | +<li>(35.1) — `I` is less than `sizeof...(Types)` and</li> |
| 45 | +<li>(35.2) — |
| 46 | +<code>is_constructible_v<T<sub>I</sub>, initializer_list<U>&, Args...></code> |
| 47 | +is `true`. |
| 48 | +</li> |
| 49 | +</ol> |
| 50 | +</p> |
| 51 | +<p>-36- <i>Effects</i>: |
| 52 | +Direct-non-list-initializes the contained value of type |
| 53 | +<tt>T<sub>I</sub></tt> with <code>il, std::forward<Args>(args)...</code>. |
| 54 | +</p> |
| 55 | +<p>-37- <i>Postconditions</i>: `index()` is `I`.</p> |
| 56 | +<p><ins>-?- <i>Throws</i>: |
| 57 | +Any exception thrown by calling the selected constructor of |
| 58 | +<tt>T<sub>I</sub></tt>. |
| 59 | +</ins> |
| 60 | +</p> |
| 61 | +<p>-38- <i>Remarks</i>: |
| 62 | +If <tt>T<sub>I</sub></tt>’s selected constructor is a constexpr constructor, |
| 63 | +this constructor is a constexpr constructor. |
| 64 | +</p> |
| 65 | +</blockquote> |
| 66 | +</blockquote> |
| 67 | +</li> |
| 68 | +</ol> |
| 69 | +</resolution> |
| 70 | + |
| 71 | +</issue> |
0 commit comments