1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-threads
10 // UNSUPPORTED: libcpp-has-no-experimental-stop_token
11 // UNSUPPORTED: c++03, c++11, c++14, c++17
12 // XFAIL: availability-synchronization_library-missing
14 // [[nodiscard]] bool operator==(const stop_source& lhs, const stop_source& rhs) noexcept;
15 // 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.
20 #include <type_traits>
22 #include "test_macros.h"
25 concept IsNoThrowEqualityComparable
= requires(const T
& t1
, const T
& t2
) {
26 { t1
== t2
} noexcept
;
29 static_assert(IsNoThrowEqualityComparable
<std::stop_source
>);
31 int main(int, char**) {
34 const std::stop_source
ss1(std::nostopstate
);
35 const std::stop_source
ss2(std::nostopstate
);
37 assert(!(ss1
!= ss2
));
40 // only one has no state
42 const std::stop_source
ss1(std::nostopstate
);
43 const std::stop_source ss2
;
44 assert(!(ss1
== ss2
));
48 // both has states. same state
50 const std::stop_source ss1
;
51 const std::stop_source
ss2(ss1
);
53 assert(!(ss1
!= ss2
));
56 // both has states. different states
58 const std::stop_source ss1
;
59 const std::stop_source ss2
;
60 assert(!(ss1
== ss2
));