brintos

brintos / llvm-project-archived public Read only

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