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 // [[nodiscard]] bool stop_possible() const noexcept; 14 // Returns: true if *this has ownership of a stop state; otherwise, false. 15 16 #include <cassert> 17 #include <stop_token> 18 #include <type_traits> 19 20 #include "test_macros.h" 21 22 template <class T> 23 concept IsStopPossibleNoexcept = requires(const T& t) { 24 { t.stop_possible() } noexcept; 25 }; 26 27 static_assert(IsStopPossibleNoexcept<std::stop_source>); 28 29 int main(int, char**) { 30 // no state 31 { 32 const std::stop_source st{std::nostopstate}; 33 assert(!st.stop_possible()); 34 } 35 36 // with state 37 { 38 const std::stop_source st; 39 assert(st.stop_possible()); 40 } 41 42 return 0; 43 } 44