Date
2016-11-28.15:43:06
Message id
8699

Content

Proposed resolution:

This wording is relative to N4606.

  1. Remove [optional.object.ctor] p3, and add a new paragraph after p6:

    optional(const optional<T>& rhs);
    

    -3- Requires: is_copy_constructible_v<T> is true.

    […]

    -?- Remarks: The function shall not participate in overload resolution unless is_copy_constructible_v<T> is true.

  2. Remove [optional.object.ctor] p7, and change p11 to:

    optional(optional<T>&& rhs) noexcept(see below);
    

    -7- Requires: is_move_constructible_v<T> is true.

    […]

    -11- Remarks: The expression inside noexcept is equivalent to is_nothrow_move_constructible_v<T>. The function shall not participate in overload resolution unless is_move_constructible_v<T> is true.

  3. Remove [optional.object.ctor] p12, and change p16 to:

    constexpr optional(const T& v);
    

    -12- Requires: is_copy_constructible_v<T> is true.

    […]

    -16- Remarks: If T's selected constructor is a constexpr constructor, this constructor shall be a constexpr constructor. The function shall not participate in overload resolution unless is_copy_constructible_v<T> is true.

  4. Remove [optional.object.ctor] p17, and change p21 to:

    constexpr optional(T&& v);
    

    -17- Requires: is_move_constructible_v<T> is true.

    […]

    -21- Remarks: If T's selected constructor is a constexpr constructor, this constructor shall be a constexpr constructor. The function shall not participate in overload resolution unless is_move_constructible_v<T> is true.

  5. Remove [optional.object.ctor] p22, and change p26 to:

    template <class... Args> 
      constexpr explicit optional(in_place_t, Args&&... args);
    

    -22- Requires: is_constructible_v<T, Args&&...> is true.

    […]

    -26- Remarks: If T's constructor selected for the initialization is a constexpr constructor, this constructor shall be a constexpr constructor. The function shall not participate in overload resolution unless is_constructible_v<T, Args...> is true.

  6. Remove [optional.object.ctor] p27.

    template <class U, class... Args> 
      constexpr explicit optional(in_place_t, initializer_list<U> il, Args&&... args);
    

    -27- Requires: is_constructible_v<T, initializer_list<U>&, Args&&...> is true.

    […]

  7. Remove [optional.object.assign] p4, and change p8 to:

    optional<T>& operator=(const optional<T>& rhs);
    

    -4- Requires: is_copy_constructible_v<T> is true and is_copy_assignable_v<T> is true.

    […]

    -8- Remarks: If any exception is thrown, the result of the expression bool(*this) remains unchanged. If an exception is thrown during the call to T's copy constructor, no effect. If an exception is thrown during the call to T's copy assignment, the state of its contained value is as defined by the exception safety guarantee of T's copy assignment. The function shall not participate in overload resolution unless is_copy_constructible_v<T> && is_copy_assignable_v<T> is true.

  8. Remove [optional.object.assign] p9, and add a new paragraph after p14:

    optional<T>& operator=(optional<T>&& rhs) noexcept(see below);
    

    -9- Requires: is_move_constructible_v<T> is true and is_move_assignable_v<T> is true.

    […]

    -14- Remarks: […] If an exception is thrown during the call to T's move assignment, the state of *val and *rhs.val is determined by the exception safety guarantee of T's move assignment.

    The function shall not participate in overload resolution unless is_move_constructible_v<T> && is_move_assignable_v<T> is true.

  9. Remove [optional.object.assign] p15, and change p19 to (yes, this wording is odd - the intent is that it will "do the right thing" after incorporation of LWG 2451):

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

    -15- Requires: is_constructible_v<T, U> is true and is_assignable_v<T&, U> is true.

    […]

    -19- Remarks: If any exception is thrown, the result of the expression bool(*this) remains unchanged. If an exception is thrown during the call to T's constructor, the state of v is determined by the exception safety guarantee of T's constructor. If an exception is thrown during the call to T's assignment, the state of *val and v is determined by the exception safety guarantee of T's assignment. The function shall not participate in overload resolution unless is_same_v<decay_t<U>, T> && is_constructible_v<T, U> && is_assignable_v<T&, U> is true.