brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · f7aa0e3 Raw
51 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// stop_token(stop_token&&) noexcept;13 14#include <cassert>15#include <stop_token>16#include <type_traits>17#include <utility>18 19#include "test_macros.h"20 21static_assert(std::is_nothrow_move_constructible_v<std::stop_token>);22 23int main(int, char**) {24  {25    std::stop_source source;26    auto st = source.get_token();27 28    assert(st.stop_possible());29    assert(!st.stop_requested());30 31    std::stop_token st2{std::move(st)};32 33    assert(!st.stop_possible());34    assert(!st.stop_requested());35 36    assert(st2.stop_possible());37    assert(!st2.stop_requested());38 39    source.request_stop();40 41    assert(!st.stop_possible());42    assert(!st.stop_requested());43 44    assert(st2.stop_possible());45    assert(st2.stop_requested());46 47  }48 49  return 0;50}51