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

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