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

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

Section: 22.8.7.4 [expected.void.assign] Status: WP Submitter: Jiang An Opened: 2023-12-16 Last modified: 2024-04-02

Priority: Not Prioritized

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

View all issues with WP 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.

[2024-03-11; Reflector poll]

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

[Tokyo 2024-03-23; Status changed: Voting → WP.]

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.