Issue 2745: [fund.ts.v2] Implementability of LWG 2451 (original) (raw)
This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of TS status.
2745. [fund.ts.v2] Implementability of LWG 2451
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(i) adds conditionally explicit converting constructors to optional<T> that accept:
- Types convertible to
T:template <class U> constexpr optional(T&&); - Rvalue
optional<U>whenU&&is convertible toT:template <class U> constexpr optional(optional<U>&&); - Lvalue
const optional<U>whenconst U&is convertible toT: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.
We should remove the "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(i), although it should be noted that this resolution should be applied wherever LWG 2451(i) 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 optional
{
public:
typedef T value_type;// 5.3.1, Constructors
[…]
template constexpr optional(U&&);
templateconstexproptional(const optional&);
templateconstexproptional(optional<U<&&);
[…]
}; - In 5.3.1 [fund.ts.v2::optional.object.ctor], modify the new signature specifications added by LWG 2451(i)
template
constexproptional(const optional& rhs);[…]
-48- Remarks:
IfThis constructor shall not participate in overload resolution unless […]T's selected constructor is aconstexprconstructor, this constructor shall be aconstexprconstructor.template
constexproptional(optional&& rhs);[…]
-53- Remarks:
IfThis constructor shall not participate in overload resolution unless […]T's selected constructor is aconstexprconstructor, this constructor shall be aconstexprconstructor.