2750. [fund.ts.v2] LWG 2451 conversion constructor constraint

Section: 99 [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.

  1. In 99 [fund.ts.v2::optional.object.ctor], modify as indicated:

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

    […]

    -43- 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 is_constructible_v<T, U&&> is true and decay_t<U> is not the same type as T. The constructor is explicit if and only if is_convertible_v<U&&, T> is false.