2842. in_place_t check for optional::optional(U&&) should decay U

Section: 23.6.3.1 [optional.ctor] Status: C++17 Submitter: Tim Song Opened: 2016-12-13 Last modified: 2017-07-30

Priority: 0

View all other issues in [optional.ctor].

View all issues with C++17 status.

Discussion:

As in_place_t is a normal tag type again, we need to decay U before doing the is_same_v check.

[2017-01-27 Telecon]

Priority 0

Proposed resolution:

This wording is relative to N4618.

  1. Edit 23.6.3.1 [optional.ctor] as indicated:

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

    […]

    -22- 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, is_same_v<decay_t<U>, in_place_t> is false, and is_same_v<optional<T>, decay_t<U>> is false. The constructor is explicit if and only if is_convertible_v<U&&, T> is false.