xref: /llvm-project/libcxx/test/std/thread/thread.stoptoken/nostopstate/cons.default.pass.cpp (revision 121ed5c1985356436d0040dbe81bca26992b1fae)
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: c++03, c++11, c++14, c++17
11 
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 
24 static_assert(std::is_trivially_default_constructible_v<std::nostopstate_t>);
25 
26 struct Empty {};
27 static_assert(sizeof(Empty) == sizeof(std::nostopstate_t));
28 
29 template <class T>
30 void conversionTest(T);
31 
32 template <class T>
33 concept ImplicitlyDefaultConstructible = requires { conversionTest<T>({}); };
34 static_assert(!ImplicitlyDefaultConstructible<std::nostopstate_t>);
35 
36 int 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