expected<cv void, E> move constructor should move
Jonathan Wakely

Created on 2022-03-23.00:00:00 last changed 1 week ago


Date: 2022-05-17.11:57:24

Proposed resolution:

This wording is relative to N4910.

  1. Modify [expected.void.assign] as indicated:

    constexpr expected& operator=(expected&& rhs) noexcept(see below);

    -4- Effects:

    1. (4.1) — If this->has_value() && rhs.has_value() is true, no effects.

    2. (4.2) — Otherwise, if this->has_value() is true, equivalent to:

      construct_at(addressof(unex), std::move(rhs.unex));
      has_val = false;
    3. (4.3) — Otherwise, if rhs.has_value() is true, destroys unex and sets has_val to true.

    4. (4.4) — Otherwise, equivalent to unex = std::move(rhs.error()).

Date: 2022-05-15.00:00:00

[ 2022-05-17; Reflector poll ]

Set status to Tentatively Ready after eight votes in favour during reflector poll.

Date: 2022-03-23.00:00:00

For expected<cv void>::operator=(expected&&) we have this in the last bullet of the Effects element:

Otherwise, equivalent to unex = rhs.error().

That should be a move assignment, not a copy assignment.

Date User Action Args
2022-05-17 11:57:24adminsetmessages: + msg12453
2022-05-17 11:57:24adminsetstatus: new -> ready
2022-03-26 13:33:21adminsetmessages: + msg12415
2022-03-23 00:00:00admincreate