brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · b1a62ba Raw
43 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// UNSUPPORTED: no-threads10// UNSUPPORTED: c++03, c++11, c++14, c++1711 12// [[nodiscard]] bool stop_possible() const noexcept;13// Returns: true if *this has ownership of a stop state; otherwise, false.14 15#include <cassert>16#include <stop_token>17#include <type_traits>18 19#include "test_macros.h"20 21template <class T>22concept IsStopPossibleNoexcept = requires(const T& t) {23  { t.stop_possible() } noexcept;24};25 26static_assert(IsStopPossibleNoexcept<std::stop_source>);27 28int main(int, char**) {29  // no state30  {31    const std::stop_source st{std::nostopstate};32    assert(!st.stop_possible());33  }34 35  // with state36  {37    const std::stop_source st;38    assert(st.stop_possible());39  }40 41  return 0;42}43