Debian Codegraph @

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

raw
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
25 static_assert(std::is_trivially_default_constructible_v<std::nostopstate_t>);
26
27 struct Empty {};
28 static_assert(sizeof(Empty) == sizeof(std::nostopstate_t));
29
30 template <class T>
31 void conversionTest(T);
32
33 template <class T>
34 concept ImplicitlyDefaultConstructible = requires { conversionTest<T>({}); };
35 static_assert(!ImplicitlyDefaultConstructible<std::nostopstate_t>);
36
37 int 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 }