Section: 22.5.3 [optional.optional] Status: Resolved Submitter: Richard Smith Opened: 2016-11-24 Last modified: 2020-11-09 21:57:32 UTC
View all other issues in [optional.optional].
View all issues with Resolved status.
LWG 2756 applies these changes:
constexpr optional(const T&); constexpr optional(T&&);template <class... Args> constexpr explicit optional(in_place_t, Args&&...); template <class U, class... Args> constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
These break the ability for optional to perform class template argument deduction, as there is now no way to map from optional's argument to the template parameter T.
[2017-01-30 Ville comments:]
Seems like the problem is resolved by a simple deduction guide:
template <class T> optional(T) -> optional<T>;
The paper p0433r0 seems to suggest a different guide,
template<class T> optional(T&& t) -> optional<remove_reference_t<T>>;
but I don't think the paper is up to speed with LWG 2756. There's no reason to use such an universal reference in the guide and remove_reference in its target, just guide with T, with the target optional<T>, optional's constructors do the right thing once the type has been deduced.
[2020-05-29; Billy Baker comments]
At Kona 2017, P0433R2 was accepted and added Ville's deduction guide rather than one proposed in P0433R0.
[2020-11-09 Resolved for C++20. Status changed: Tentatively Resolved → Resolved.]
Rationale:Resolved by P0433R2.