4025. Move assignment operator of std::expected<cv void, E> should not be conditionally deleted

Section: 22.8.7.4 [expected.void.assign] Status: New Submitter: Jiang An Opened: 2023-12-16 Last modified: 2023-12-22 10:28:38 UTC

Priority: Not Prioritized

View all other issues in [expected.void.assign].

View all issues with New status.

Discussion:

It seems intended that copy functions of std::optional, std::variant, and std::expected are conditionally deleted, while move functions are constrained. However, the move assignment operator of std::expected<cv void, E> is currently conditionally deleted, which is inconsistent.

Proposed resolution:

This wording is relative to N4971.

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

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

    -?- Constraints: is_move_constructible_v<E> is true and is_move_assignable_v<E> is true.

    […]

    -6- Remarks: The exception specification is equivalent to is_nothrow_move_constructible_v<E> && is_nothrow_move_assignable_v<E>.

    -7- This operator is defined as deleted unless is_move_constructible_v<E> is true and is_move_assignable_v<E> is true.