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: c++03, c++11, c++14, c++17
11 // XFAIL: availability-synchronization_library-missing
13 // stop_source& operator=(stop_source&& rhs) noexcept;
18 #include <type_traits>
21 #include "test_macros.h"
23 static_assert(std::is_nothrow_move_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
= std::move(ss2
);
41 assert(ss1
.stop_requested());
42 assert(!ss2
.stop_possible());
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
= std::move(ss2
);
63 assert(ss1
.stop_requested());
64 assert(ss1
.stop_possible());
65 assert(!ss2
.stop_requested());
66 assert(!ss2
.stop_possible());
72 std::stop_source ss2
{std::nostopstate
};
78 assert(ss1
.stop_requested());
79 assert(ss1
.stop_possible());
80 assert(!ss2
.stop_requested());
81 assert(!ss2
.stop_possible());
83 std::same_as
<std::stop_source
&> decltype(auto) ref
= ss1
= std::move(ss2
);
87 assert(!ss1
.stop_requested());
88 assert(!ss1
.stop_possible());
89 assert(!ss2
.stop_requested());
90 assert(!ss2
.stop_possible());
95 std::stop_source ss1
{std::nostopstate
};
96 std::stop_source ss2
{std::nostopstate
};
100 assert(!ss1
.stop_requested());
101 assert(!ss1
.stop_possible());
102 assert(!ss2
.stop_requested());
103 assert(!ss2
.stop_possible());
105 std::same_as
<std::stop_source
&> decltype(auto) ref
= ss1
= std::move(ss2
);
106 assert(&ref
== &ss1
);
109 assert(!ss1
.stop_requested());
110 assert(!ss1
.stop_possible());
111 assert(!ss2
.stop_requested());
112 assert(!ss2
.stop_possible());
120 assert(!ss
.stop_requested());
122 std::same_as
<std::stop_source
&> decltype(auto) ref
= ss
= std::move(self
);
125 assert(!ss
.stop_requested());
128 assert(ss
.stop_requested());