This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

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

Section: 22.5.3.2 [optional.ctor] Status: C++17 Submitter: Tim Song Opened: 2016-12-13 Last modified: 2020-09-06

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 22.5.3.2 [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.