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

source code of libcxx/test/std/thread/thread.stoptoken/stoptoken/cons.move.pass.cpp