Section: 5.3 [fund.ts.v2::optional.object] Status: TS Submitter: Casey Carter Opened: 2016-07-10 Last modified: 2018-07-08
Priority: 0
View all other issues in [fund.ts.v2::optional.object].
View all issues with TS status.
Discussion:
Addresses: fund.ts.v2
LWG 2451 adds conditionally explicit converting constructors to optional<T> that accept:
T: template <class U> constexpr optional(T&&);optional<U> when U&& is convertible to T:
template <class U> constexpr optional(optional<U>&&);const optional<U> when const U& is convertible to T:
template <class U> constexpr optional(const optional<U>&);
All three of these constructors are required to be constexpr "If T's selected constructor is a
constexpr constructor". While this is not problematic for #1, it is not possible in the current language
to implement signatures #2 and #3 as constexpr functions for the same reasons that optional's
non-converting constructors from optional<T>&& and const optional<T>&
cannot be constexpr.
constexpr" specifier from the declarations of the conditionally explicit converting
constructors that accept optional<U>&& and const optional<U>&, and strike
the remarks requiring these constructors to be constexpr.
[2016-07 Chicago]
Monday: P0 - tentatively ready
This needs to be considered for C++17 as well
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
optionalin the C++ Working Paper.
Edit 22.5.3 [optional.optional] as indicated:
template <class T>
class optional
{
public:
typedef T value_type;
// 5.3.1, Constructors
[…]
template <class U> constexpr optional(U&&);
template <class U> constexpr optional(const optional<U>&);
template <class U> constexpr optional(optional<U<&&);
[…]
};
In 5.3.1 [fund.ts.v2::optional.object.ctor], modify the new signature specifications added by LWG 2451
template <class U>constexproptional(const optional<U>& rhs);[…]
-48- Remarks:IfThis constructor shall not participate in overload resolution unless […]T's selected constructor is aconstexprconstructor, this constructor shall be aconstexprconstructor.template <class U>constexproptional(optional<U>&& rhs);[…]
-53- Remarks:IfThis constructor shall not participate in overload resolution unless […]T's selected constructor is aconstexprconstructor, this constructor shall be aconstexprconstructor.