From a4a1f96551882663b7eb75cf09c00ab9052dd08d Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 6 Jan 2020 12:06:47 +0000 Subject: [PATCH] libstdc++: Remove redundant inequality operators in * 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. From-SVN: r279897 --- libstdc++-v3/ChangeLog | 5 +++ libstdc++-v3/include/std/stop_token | 18 +--------- .../30_threads/stop_token/stop_source.cc | 35 +++++++++++++++++++ 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1fe69c46c75..1e46178c999 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,10 @@ 2020-01-06 Jonathan Wakely + * 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. + * include/bits/stl_algobase.h (__is_byte_iter, __min_cmp) (lexicographical_compare_three_way): Do not depend on __cpp_lib_concepts. 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() -- 2.30.2