aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-01-06 12:06:47 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2020-01-06 12:06:47 +0000
commita4a1f96551882663b7eb75cf09c00ab9052dd08d (patch)
tree719a7391b8f5f437de05a2881942bbb87e20cf4c /libstdc++-v3
parentf31a99f7c1239d0bde7b1f60e664ee98020bd4e0 (diff)
downloadgcc-a4a1f96551882663b7eb75cf09c00ab9052dd08d.zip
gcc-a4a1f96551882663b7eb75cf09c00ab9052dd08d.tar.gz
gcc-a4a1f96551882663b7eb75cf09c00ab9052dd08d.tar.bz2
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. From-SVN: r279897
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/include/std/stop_token18
-rw-r--r--libstdc++-v3/testsuite/30_threads/stop_token/stop_source.cc35
3 files changed, 41 insertions, 17 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 1fe69c4..1e46178 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,10 @@
2020-01-06 Jonathan Wakely <jwakely@redhat.com>
+ * 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 58f7279..e23d139 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 707c421..9d15f07 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()