This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
variant constructorSection: 22.6.3.2 [variant.ctor] Status: New Submitter: Jonathan Wakely Opened: 2025-11-07 Last modified: 2025-11-07
Priority: Not Prioritized
View other active issues in [variant.ctor].
View all other issues in [variant.ctor].
View all issues with New status.
Discussion:
All variant constructors except the last one have a Throws: element
saying what they're allowed to throw.
This originates from an editorial pull request, where the submitter said:
"It looks like this defect is an artifact of a change between P0088R0 and P0088R1. Note how in R0 neither one of theemplaced_type_t/emplaced_index_t(as they were then called) +initializer_listconstructors have a throws clause. In R1 only one of them gained it."
Proposed resolution:
This wording is relative to N5014.
Modify 22.6.3.2 [variant.ctor], as indicated:
template<size_t I, class U, class... Args> constexpr explicit variant(in_place_index_t<I>, initializer_list<U> il, Args&&... args);-35- Constraints:
- (35.1) —
Iis less thansizeof...(Types)and- (35.2) —
is_constructible_v<TI, initializer_list<U>&, Args...>istrue.-36- Effects: Direct-non-list-initializes the contained value of type
TIwithil, std::forward<Args>(args)....-37- Postconditions:
index()isI.-?- Throws: Any exception thrown by calling the selected constructor of
TI.-38- Remarks: If
TI’s selected constructor is a constexpr constructor, this constructor is a constexpr constructor.