Title
[fund.ts.v2] Implementability of LWG 2451
Status
open
Section
[optional.object]
Submitter
Casey Carter

Created on 2016-07-10.00:00:00 last changed 82 months ago

Messages

Date: 2016-11-26.14:34:13

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.

  1. Edit [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<&&);
      […]
    };
    
  2. In [optional.object.ctor], modify the new signature specifications added by LWG 2451

    template <class U>
      constexpr optional(const optional<U>& rhs);
    

    […]

    -48- Remarks: If T's selected constructor is a constexpr constructor, this constructor shall be a constexpr constructor. This constructor shall not participate in overload resolution unless […]

    template <class U>
      constexpr optional(optional<U>&& rhs);
    

    […]

    -53- Remarks: If T's selected constructor is a constexpr constructor, this constructor shall be a constexpr constructor. This constructor shall not participate in overload resolution unless […]

Date: 2016-08-01.18:34:48

[ 2016-07 Chicago ]

Monday: P0 - tentatively ready

This needs to be considered for C++17 as well

Date: 2016-07-10.00:00:00

Addresses: fund.ts.v2

LWG 2451 adds conditionally explicit converting constructors to optional<T> that accept:

  1. Types convertible to T: template <class U> constexpr optional(T&&);
  2. Rvalue optional<U> when U&& is convertible to T: template <class U> constexpr optional(optional<U>&&);
  3. Lvalue 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.

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.

History
Date User Action Args
2017-07-30 20:10:41adminsetstatus: wp -> open
2016-11-14 03:59:28adminsetstatus: pending -> wp
2016-11-14 03:55:22adminsetstatus: ready -> pending
2016-08-01 18:34:48adminsetmessages: + msg8283
2016-08-01 18:34:48adminsetstatus: new -> ready
2016-07-24 19:26:01adminsetmessages: + msg8248
2016-07-10 00:00:00admincreate