Created on 2016-10-29.00:00:00 last changed 55 months ago
Proposed resolution:
This wording is relative to N4861.
Modify [optional.ctor] as indicated:
constexpr optional(const optional& rhs);-3- […]
-4- […] -5- Throws: Any exception thrown by theselected constructor of Tinitialization of the contained value.constexpr optional(optional&& rhs) noexcept(see below);-7- […]
[…] -10- Throws: Any exception thrown by theselected constructor of Tinitialization of the contained value.template<class... Args> constexpr explicit optional(in_place_t, Args&&... args);-12- […]
[…] -15- Throws: Any exception thrown by theselected constructor of Tinitialization of the contained value.template<class U, class... Args> constexpr explicit optional(in_place_t, initializer_list<U> il, Args&&... args);-17- […]
[…] -20- Throws: Any exception thrown by theselected constructor of Tinitialization of the contained value.template<class U = T> constexpr explicit(see below) optional(U&& v);-22- […]
[…] -25- Throws: Any exception thrown by theselected constructor of Tinitialization of the contained value.template<class U> explicit(see below) optional(const optional<U>& rhs);-27- […]
[…] -30- Throws: Any exception thrown by theselected constructor of Tinitialization of the contained value.template<class U> explicit(see below) optional(optional<U>&& rhs);-32- […]
[…] -35- Throws: Any exception thrown by theselected constructor of Tinitialization of the contained value.
Modify [variant.ctor] as indicated:
template<class T, class... Args> constexpr explicit variant(in_place_type_t<T>, Args&&... args);-20- […]
[…] -23- Throws: Any exception thrown bycalling the selected constructor of Tthe initialization of the contained value.template<class T, class U, class... Args> constexpr explicit variant(in_place_type_t<T>, initializer_list<U> il, Args&&... args);-25- […]
[…] -28- Throws: Any exception thrown bycalling the selected constructor of Tthe initialization of the contained value.template<size_t I, class... Args> constexpr explicit variant(in_place_index_t<I>, Args&&... args);-30 […]
[…] -33- Throws: Any exception thrown bycalling the selected constructor of TIthe initialization of the contained value.
Modify [any.cons] as indicated:
any(const any& other);[…]-2- Effects: […]
-3- Throws: Any exceptionsarising from calling the selected constructor forthrown by the initialization of the contained value.template<class T> any(T&& value);-5- […]
[…] -9- Throws: Any exception thrown by theselected constructor of VTinitialization of the contained value.template<class T, class... Args> explicit any(in_place_type_t<T>, Args&&... args);-10- […]
[…] -15- Throws: Any exception thrown by theselected constructor of VTinitialization of the contained value.template<class T, class U, class... Args> explicit any(in_place_type_t<T>, initializer_list<U> il, Args&&... args);-16- […]
[…] -21- Throws: Any exception thrown by theselected constructor of VTinitialization of the contained value.
Modify [any.modifiers] as indicated:
template<class T, class... Args> decay_t<T>& emplace(Args&&... args);-1- […]
[…] -7- Throws: Any exception thrown by theselected constructor of VTinitialization of the contained value. -8- […]template<class T, class U, class... Args> decay_t<T>& emplace(initializer_list<U> il, Args&&... args);-9- […]
[…] -15- Throws: Any exception thrown by theselected constructor of VTinitialization of the contained value.
[ 2020-06-11; Nina Dinka Ranns comments and provides initial wording ]
This wording depends on the current resolution for LWG 2833, which covers the constexpr portion of this issue.
[ Issues Telecon 16-Dec-2016 ]
Priority 3; Jonathan to provide wording.
Throughout optional/variant/any's specification references are made to "the selected constructor of T". For example, [optional.ctor]/16 says of the constructor from const T&:
-16- Remarks: If T's selected constructor is a constexpr constructor, this constructor shall be a constexpr constructor.
Similarly, the in-place constructor has this wording ([optional.ctor]/25-26):
-25- Throws: Any exception thrown by the selected constructor of T.
-26- Remarks: If T's constructor selected for the initialization is a constexpr constructor, this constructor shall be a constexpr constructor.
If T is a scalar type, it has no constructor at all. Moreover, even for class types, the in-place constructor wording ignores any implicit conversion done on the argument before the selected constructor is called, which 1) may not be valid in constant expressions and 2) may throw an exception; such exceptions aren't thrown "by the selected constructor of T" but outside it.
The wording should probably be recast to refer to the entire initialization.History | |||
---|---|---|---|
Date | User | Action | Args |
2020-06-13 19:09:04 | admin | set | messages: + msg11335 |
2020-06-13 19:09:04 | admin | set | messages: + msg11334 |
2016-12-16 20:56:38 | admin | set | messages: + msg8742 |
2016-10-29 00:00:00 | admin | create |