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.

3951. §[expected.object.swap]: Using value() instead of has_value()

Section: 22.8.6.5 [expected.object.swap], 22.8.7.5 [expected.void.swap] Status: WP Submitter: Ben Craig Opened: 2023-06-25 Last modified: 2023-11-22

Priority: Not Prioritized

View all issues with WP status.

Discussion:

22.8.6.5 [expected.object.swap] p2 has the following text in it:

For the case where rhs.value() is false and this->has_value() is true, equivalent to: […]

The table preceding that text is a table of this->has_value() vs. rhs.has_value(). The rhs.value() in the text is almost certainly a typo, as a .value() call here doesn't make any sense, especially if this is an expected<non-bool, E>.

The same issue is there for 22.8.7.5 [expected.void.swap] p2.

[2023-10-27; Reflector poll]

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

[2023-11-11 Approved at November 2023 meeting in Kona. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4950.

  1. Modify 22.8.6.5 [expected.object.swap] as indicated:

    constexpr void swap(expected& rhs) noexcept(see below);
    

    -1- […]

    -2- Effects: See Table 63 [tab:expected.object.swap].

    For the case where rhs.has_value() is false and this->has_value() is true, equivalent to: […]

  2. Modify 22.8.7.5 [expected.void.swap] as indicated:

    constexpr void swap(expected& rhs) noexcept(see below);
    

    -1- […]

    -2- Effects: See Table 64 [tab:expected.void.swap].

    For the case where rhs.has_value() is false and this->has_value() is true, equivalent to: […]