[DependencyScanning] Add ability to scan TU with a buffer input (#125111)
[llvm-project.git] / libcxx / test / std / thread / thread.stoptoken / stoptoken / assign.move.pass.cpp
blob2a94bebb62aa8a88c4e7e0a4960da6c148d0d7f5
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
13 // stop_token& operator=(stop_token&& rhs) noexcept;
15 #include <cassert>
16 #include <concepts>
17 #include <stop_token>
18 #include <type_traits>
19 #include <utility>
21 #include "test_macros.h"
23 static_assert(std::is_nothrow_move_assignable_v<std::stop_token>);
25 int main(int, char**) {
27 std::stop_token st1;
29 std::stop_source source;
30 auto st2 = source.get_token();
32 assert(st1 != st2);
34 source.request_stop();
36 assert(!st1.stop_requested());
37 assert(st2.stop_requested());
39 std::same_as<std::stop_token&> decltype(auto) ref = st1 = std::move(st2);
40 assert(&ref == &st1);
42 assert(st1 != st2);
43 assert(st1.stop_requested());
44 assert(!st2.stop_requested());
47 return 0;