42 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// struct nostopstate_t {13// explicit nostopstate_t() = default;14// };15//16// inline constexpr nostopstate_t nostopstate{};17 18#include <concepts>19#include <stop_token>20#include <type_traits>21 22#include "test_macros.h"23 24static_assert(std::is_trivially_default_constructible_v<std::nostopstate_t>);25 26struct Empty {};27static_assert(sizeof(Empty) == sizeof(std::nostopstate_t));28 29template <class T>30void conversionTest(T);31 32template <class T>33concept ImplicitlyDefaultConstructible = requires { conversionTest<T>({}); };34static_assert(!ImplicitlyDefaultConstructible<std::nostopstate_t>);35 36int main(int, char**) {37 [[maybe_unused]] std::same_as<std::nostopstate_t> auto x = std::nostopstate;38 [[maybe_unused]] auto y = std::nostopstate_t{};39 40 return 0;41}42