Title
Strike stop_token's operator!=
Status
c++20
Section
[stoptoken]
Submitter
Casey Carter

Created on 2019-08-06.00:00:00 last changed 45 months ago

Messages

Date: 2020-01-05.16:13:01

Proposed resolution:

This wording is relative to N4830.

  1. Modify [stoptoken], class stop_token synopsis, as indicated:

    namespace std {
      class stop_token {
      public:  
        […]
        [[nodiscard]] friend bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
        [[nodiscard]] friend bool operator!=(const stop_token& lhs, const stop_token& rhs) noexcept;
        friend void swap(stop_token& lhs, stop_token& rhs) noexcept;
      };
    }
    
  2. Modify [stoptoken.cmp] and [stoptoken.special] as indicated:

    32.3.3.3 Non-member functionsComparisons [stoptoken.nonmemberscmp]

    [[nodiscard]] bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
    

    -1- Returns: true if lhs and rhs have ownership of the same stop state or if both lhs and rhs do not have ownership of a stop state; otherwise false.

    [[nodiscard]] bool operator!=(const stop_token& lhs, const stop_token& rhs) noexcept;
    

    -2- Returns: !(lhs==rhs).

    32.3.3.4 Specialized algorithms [stoptoken.special]

    friend void swap(stop_token& x, stop_token& y) noexcept;
    

    -1- Effects: Equivalent to: x.swap(y).

Date: 2020-01-05.16:13:01

[ 01-2020 Moved to Tentatively Ready after 5 positive votes on the reflector. ]

Date: 2019-08-06.00:00:00

In the shiny new world of the future, we need not declare overloads of operator!= that return !(x == y); the rewrite rule in [over.match.oper] para 3.4.3 achieves the same effect. Consequently, we should not declare such unnecessary operator!= overloads. The synopsis of class stop_token in [stoptoken] declares exactly such an operator!= friend which should be struck.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: voting -> wp
2020-01-17 04:54:50adminsetstatus: ready -> voting
2020-01-05 16:13:01adminsetmessages: + msg10905
2020-01-05 16:13:01adminsetstatus: new -> ready
2019-08-17 14:16:58adminsetmessages: + msg10559
2019-08-06 00:00:00admincreate