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: c++03, c++11, c++14, c++17 |
11 | // XFAIL: availability-synchronization_library-missing |
12 | |
13 | // stop_source(stop_source&&) noexcept; |
14 | |
15 | #include <cassert> |
16 | #include <stop_token> |
17 | #include <type_traits> |
18 | #include <utility> |
19 | |
20 | #include "test_macros.h" |
21 | |
22 | static_assert(std::is_nothrow_move_constructible_v<std::stop_source>); |
23 | |
24 | int main(int, char**) { |
25 | { |
26 | std::stop_source source; |
27 | |
28 | assert(source.stop_possible()); |
29 | assert(!source.stop_requested()); |
30 | |
31 | std::stop_source source2{std::move(source)}; |
32 | |
33 | assert(!source.stop_possible()); |
34 | assert(!source.stop_requested()); |
35 | |
36 | assert(source2.stop_possible()); |
37 | assert(!source2.stop_requested()); |
38 | |
39 | source2.request_stop(); |
40 | |
41 | assert(!source.stop_possible()); |
42 | assert(!source.stop_requested()); |
43 | |
44 | assert(source2.stop_possible()); |
45 | assert(source2.stop_requested()); |
46 | } |
47 | |
48 | return 0; |
49 | } |
50 | |