brintos

brintos / llvm-project-archived public Read only

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