Section: 5.3.1 [fund.ts.v2::optional.object.ctor] Status: TS Submitter: Casey Carter Opened: 2016-07-20 Last modified: 2017-07-30
Priority: 0
View all issues with TS status.
Discussion:
Addresses: fund.ts.v2
LWG 2451 adds a converting constructor to optional
with signature:
template <class U> constexpr optional(U&& v);
and specifies that "This constructor shall not participate in overload resolution unless
is_constructible_v<T, U&&>
is true
and U
is not the same type as T
."
This suffices to avoid this constructor being selected by overload resolution for arguments that should match the
move constructor, but not for arguments that should match the copy constructor. The recent churn around tuple's
constructors suggests that we want this constructor to not participate in overload resolution if
remove_cv_t<remove_reference_t<U>>
is the same type as T
.
[2016-07 Chicago]
Monday: P0 - tentatively ready
Proposed resolution:
This wording is relative to N4600.
Wording relative to N4600 + LWG 2451, although it should be noted that this resolution should be applied wherever LWG 2451 is applied, be that to the fundamentals TS or the specification of
optional
in the C++ Working Paper.
In 5.3.1 [fund.ts.v2::optional.object.ctor], modify as indicated:
template <class U> constexpr optional(U&& v);[…]
-43- Remarks: IfT
's selected constructor is aconstexpr
constructor, this constructor shall be aconstexpr
constructor. This constructor shall not participate in overload resolution unlessis_constructible_v<T, U&&>
istrue
anddecay_t<U>
is not the same type asT
. The constructor is explicit if and only ifis_convertible_v<U&&, T>
isfalse
.