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