libstdc++: Remove redundant inequality operators in <stop_token>

Message ID 20200106120630.GA578471@redhat.com
State New
Headers show
Series
  • libstdc++: Remove redundant inequality operators in <stop_token>
Related show

Commit Message

Jonathan Wakely Jan. 6, 2020, 12:06 p.m.
* include/std/stop_token (stop_token): Remove operator!= (LWG 3254).
	(stop_source): Likewise (LWG 3362).
	* testsuite/30_threads/stop_token/stop_source.cc: Test equality
	comparisons.

Tested powerpc64le-linux, committed to trunk.
commit 55ac97433857c19cd9ecf3fbf6e35583d72da86d
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jan 6 11:26:16 2020 +0000

    libstdc++: Remove redundant inequality operators in <stop_token>
    
            * include/std/stop_token (stop_token): Remove operator!= (LWG 3254).
            (stop_source): Likewise (LWG 3362).
            * testsuite/30_threads/stop_token/stop_source.cc: Test equality
            comparisons.

Patch

diff --git a/libstdc++-v3/include/std/stop_token b/libstdc++-v3/include/std/stop_token
index 58f72792b9e..e23d139e66c 100644
--- a/libstdc++-v3/include/std/stop_token
+++ b/libstdc++-v3/include/std/stop_token
@@ -87,16 +87,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
     [[nodiscard]]
     friend bool
     operator==(const stop_token& __a, const stop_token& __b)
-    {
-      return __a._M_state == __b._M_state;
-    }
-
-    [[nodiscard]]
-    friend bool
-    operator!=(const stop_token& __a, const stop_token& __b)
-    {
-      return __a._M_state != __b._M_state;
-    }
+    { return __a._M_state == __b._M_state; }
 
     friend void
     swap(stop_token& __lhs, stop_token& __rhs) noexcept
@@ -301,13 +292,6 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __a._M_state == __b._M_state;
     }
 
-    [[nodiscard]]
-    friend bool
-    operator!=(const stop_source& __a, const stop_source& __b) noexcept
-    {
-      return __a._M_state != __b._M_state;
-    }
-
     friend void
     swap(stop_source& __lhs, stop_source& __rhs) noexcept
     {
diff --git a/libstdc++-v3/testsuite/30_threads/stop_token/stop_source.cc b/libstdc++-v3/testsuite/30_threads/stop_token/stop_source.cc
index 707c421ce32..9d15f0781ea 100644
--- a/libstdc++-v3/testsuite/30_threads/stop_token/stop_source.cc
+++ b/libstdc++-v3/testsuite/30_threads/stop_token/stop_source.cc
@@ -27,12 +27,18 @@  test01()
   std::stop_source ssrc;
   VERIFY( ssrc.stop_possible() );
   VERIFY( !ssrc.stop_requested() );
+  VERIFY( ssrc == ssrc );
+  VERIFY( !(ssrc != ssrc) );
 
   std::stop_source copy(ssrc);
   VERIFY( copy.stop_possible() );
   VERIFY( !copy.stop_requested() );
   VERIFY( ssrc.stop_possible() );
   VERIFY( !ssrc.stop_requested() );
+  VERIFY( copy == ssrc );
+  VERIFY( !(copy != ssrc) );
+  VERIFY( ssrc == ssrc );
+  VERIFY( !(ssrc != ssrc) );
 
   std::stop_source move(std::move(ssrc));
   VERIFY( move.stop_possible() );
@@ -41,6 +47,14 @@  test01()
   VERIFY( !copy.stop_requested() );
   VERIFY( !ssrc.stop_possible() );
   VERIFY( !ssrc.stop_requested() );
+  VERIFY( !(move == ssrc) );
+  VERIFY( move != ssrc );
+  VERIFY( ssrc == ssrc );
+  VERIFY( !(ssrc != ssrc) );
+  VERIFY( move == copy );
+  VERIFY( !(move != copy) );
+  VERIFY( !(copy == ssrc) );
+  VERIFY( copy != ssrc );
 }
 
 void
@@ -52,12 +66,18 @@  test02()
   std::stop_source ssrc(std::nostopstate);
   VERIFY( !ssrc.stop_possible() );
   VERIFY( !ssrc.stop_requested() );
+  VERIFY( ssrc == ssrc );
+  VERIFY( !(ssrc != ssrc) );
 
   std::stop_source copy(ssrc);
   VERIFY( !copy.stop_possible() );
   VERIFY( !copy.stop_requested() );
   VERIFY( !ssrc.stop_possible() );
   VERIFY( !ssrc.stop_requested() );
+  VERIFY( copy == ssrc );
+  VERIFY( !(copy != ssrc) );
+  VERIFY( ssrc == ssrc );
+  VERIFY( !(ssrc != ssrc) );
 
   std::stop_source move(std::move(ssrc));
   VERIFY( !move.stop_possible() );
@@ -66,24 +86,39 @@  test02()
   VERIFY( !copy.stop_requested() );
   VERIFY( !ssrc.stop_possible() );
   VERIFY( !ssrc.stop_requested() );
+  VERIFY( move == ssrc );
+  VERIFY( !(move != ssrc) );
+  VERIFY( ssrc == ssrc );
+  VERIFY( !(ssrc != ssrc) );
+  VERIFY( move == copy );
+  VERIFY( !(move != copy) );
+  VERIFY( copy == ssrc );
+  VERIFY( !(copy != ssrc) );
 }
 
 void
 test03()
 {
   std::stop_source s1;
+  std::stop_source copy(s1);
   s1.request_stop();
   std::stop_source s2(std::nostopstate);
+  VERIFY( s1 != s2 );
+
   s1.swap(s2);
   VERIFY( !s1.stop_possible() );
   VERIFY( !s1.stop_requested() );
   VERIFY( s2.stop_possible() );
   VERIFY( s2.stop_requested() );
+  VERIFY( s1 != s2 );
+  VERIFY( s2 == copy );
+
   swap(s1, s2);
   VERIFY( s1.stop_possible() );
   VERIFY( s1.stop_requested() );
   VERIFY( !s2.stop_possible() );
   VERIFY( !s2.stop_requested() );
+  VERIFY( s1 == copy );
 }
 
 int main()