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

Created on 2019-08-06.00:00:00, last changed 2019-08-17.14:16:58.

Messages

Date: 2019-08-17.14:16:58

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: 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
2019-08-17 14:16:58adminsetmessages: + msg10559
2019-08-06 00:00:00admincreate