[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / thread.stoptoken / stoptoken / equals.pass.cpp
blob4de9b81f718685d06edcd831740c8394aa788496
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
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_token& lhs, const stop_token& 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.
17 // synthesized operator != also tested.
19 #include <cassert>
20 #include <concepts>
21 #include <stop_token>
22 #include <type_traits>
24 #include "test_macros.h"
26 // LWG 3254 is related.
27 template <class T>
28 concept IsNoThrowEqualityComparable = requires(const T& t1, const T& t2) {
29 { t1 == t2 } noexcept;
32 template <class T>
33 concept IsNoThrowInequalityComparable = requires(const T& t1, const T& t2) {
34 { t1 != t2 } noexcept;
37 static_assert(IsNoThrowEqualityComparable<std::stop_token>);
38 static_assert(IsNoThrowInequalityComparable<std::stop_token>);
40 int main(int, char**) {
41 // both no state
43 const std::stop_token st1;
44 const std::stop_token st2;
45 assert(st1 == st2);
46 assert(!(st1 != st2));
49 // only one has no state
51 std::stop_source ss;
52 const std::stop_token st1;
53 const auto st2 = ss.get_token();
54 assert(!(st1 == st2));
55 assert(st1 != st2);
58 // both has states. same source
60 std::stop_source ss;
61 const auto st1 = ss.get_token();
62 const auto st2 = ss.get_token();
63 assert(st1 == st2);
64 assert(!(st1 != st2));
67 // both has states. different sources with same states
69 std::stop_source ss1;
70 auto ss2 = ss1;
71 const auto st1 = ss1.get_token();
72 const auto st2 = ss2.get_token();
73 assert(st1 == st2);
74 assert(!(st1 != st2));
77 // both has states. different sources with different states
79 std::stop_source ss1;
80 std::stop_source ss2;
81 const auto st1 = ss1.get_token();
82 const auto st2 = ss2.get_token();
83 assert(!(st1 == st2));
84 assert(st1 != st2);
87 return 0;