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

source code of libcxx/test/std/thread/thread.stoptoken/nostopstate/cons.default.pass.cpp