Date
2016-09-12.04:46:33
Message id
8516

Content

Proposed resolution:

This wording is relative to N4606.

  1. Modify [variant.swap] as indicated:

    void swap(variant& rhs) noexcept(see below);
    

    -?- Requires: Lvalues of type Ti shall be swappable and is_move_constructible_v<Ti> shall be true for all i.

    […]

    -2- Throws: If index() == rhs.index(), aAny exception thrown by swap(get<i>(*this), get<i>(rhs)) with i being index() and variant's move constructor and assignment operator. Otherwise, any exception thrown by the move constructor of Ti or Tj with i being index() and j being rhs.index().

    -3- Remarks: This function shall not participate in overload resolution unless is_swappable_v<Ti> is true for all i. If an exception is thrown during the call to function swap(get<i>(*this), get<i>(rhs)), the states of the contained values of *this and of rhs are determined by the exception safety guarantee of swap for lvalues of Ti with i being index(). If an exception is thrown during the exchange of the values of *this and rhs, the states of the values of *this and of rhs are determined by the exception safety guarantee of variant's move constructor and move assignment operator. The expression inside noexcept is equivalent to the logical AND of is_nothrow_move_constructible_v<Ti> && is_nothrow_swappable_v<Ti> for all i.

  2. Modify [variant.specalg] as indicated:

    template <class... Types> void swap(variant<Types...>& v, variant<Types...>& w) noexcept(see below);
    

    -1- Effects: Equivalent to v.swap(w).

    -2- Remarks: This function shall not participate in overload resolution unless is_move_constructible_v<Ti> && is_swappable_v<Ti> is true for all i. The expression inside noexcept is equivalent to noexcept(v.swap(w)).