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 // stop_source& operator=(const stop_source& rhs) noexcept;
19 #include <type_traits>
21 #include "test_macros.h"
23 static_assert(std::is_nothrow_copy_assignable_v
<std::stop_source
>);
25 int main(int, char**) {
26 // have two different states
35 assert(!ss1
.stop_requested());
36 assert(ss2
.stop_requested());
38 std::same_as
<std::stop_source
&> decltype(auto) ref
= ss1
= ss2
;
42 assert(ss1
.stop_requested());
43 assert(ss2
.stop_requested());
48 std::stop_source ss1
{std::nostopstate
};
55 assert(!ss1
.stop_requested());
56 assert(!ss1
.stop_possible());
57 assert(ss2
.stop_requested());
58 assert(ss2
.stop_possible());
60 std::same_as
<std::stop_source
&> decltype(auto) ref
= ss1
= ss2
;
64 assert(ss1
.stop_requested());
65 assert(ss1
.stop_possible());
66 assert(ss2
.stop_requested());
67 assert(ss2
.stop_possible());
73 std::stop_source ss2
{std::nostopstate
};
79 assert(ss1
.stop_requested());
80 assert(ss1
.stop_possible());
81 assert(!ss2
.stop_requested());
82 assert(!ss2
.stop_possible());
84 std::same_as
<std::stop_source
&> decltype(auto) ref
= ss1
= ss2
;
88 assert(!ss1
.stop_requested());
89 assert(!ss1
.stop_possible());
90 assert(!ss2
.stop_requested());
91 assert(!ss2
.stop_possible());
96 std::stop_source ss1
{std::nostopstate
};
97 std::stop_source ss2
{std::nostopstate
};
101 assert(!ss1
.stop_requested());
102 assert(!ss1
.stop_possible());
103 assert(!ss2
.stop_requested());
104 assert(!ss2
.stop_possible());
106 std::same_as
<std::stop_source
&> decltype(auto) ref
= ss1
= ss2
;
107 assert(&ref
== &ss1
);
110 assert(!ss1
.stop_requested());
111 assert(!ss1
.stop_possible());
112 assert(!ss2
.stop_requested());
113 assert(!ss2
.stop_possible());
121 assert(!ss
.stop_requested());
123 std::same_as
<std::stop_source
&> decltype(auto) ref
= ss
= self
;
126 assert(!ss
.stop_requested());
129 assert(ss
.stop_requested());