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
This commit is contained in:
Jonathan Wakely 2020-01-06 12:06:47 +00:00 committed by Jonathan Wakely
parent f31a99f7c1
commit a4a1f96551
3 changed files with 41 additions and 17 deletions

View File

@ -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.

View File

@ -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
{

View File

@ -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()