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// WARNING: This test was generated by generate_feature_test_macro_components.py
10// and should not be edited manually.
11//
12// clang-format off
13
14// UNSUPPORTED: no-threads
15
16// <thread>
17
18// Test the feature test macros defined by <thread>
19
20/* Constant Value
21 __cpp_lib_formatters 202302L [C++23]
22 __cpp_lib_jthread 201911L [C++20]
23*/
24
25#include <thread>
26#include "test_macros.h"
27
28#if TEST_STD_VER < 14
29
30# ifdef __cpp_lib_formatters
31# error "__cpp_lib_formatters should not be defined before c++23"
32# endif
33
34# ifdef __cpp_lib_jthread
35# error "__cpp_lib_jthread should not be defined before c++20"
36# endif
37
38#elif TEST_STD_VER == 14
39
40# ifdef __cpp_lib_formatters
41# error "__cpp_lib_formatters should not be defined before c++23"
42# endif
43
44# ifdef __cpp_lib_jthread
45# error "__cpp_lib_jthread should not be defined before c++20"
46# endif
47
48#elif TEST_STD_VER == 17
49
50# ifdef __cpp_lib_formatters
51# error "__cpp_lib_formatters should not be defined before c++23"
52# endif
53
54# ifdef __cpp_lib_jthread
55# error "__cpp_lib_jthread should not be defined before c++20"
56# endif
57
58#elif TEST_STD_VER == 20
59
60# ifdef __cpp_lib_formatters
61# error "__cpp_lib_formatters should not be defined before c++23"
62# endif
63
64# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
65# ifndef __cpp_lib_jthread
66# error "__cpp_lib_jthread should be defined in c++20"
67# endif
68# if __cpp_lib_jthread != 201911L
69# error "__cpp_lib_jthread should have the value 201911L in c++20"
70# endif
71# else
72# ifdef __cpp_lib_jthread
73# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
74# endif
75# endif
76
77#elif TEST_STD_VER == 23
78
79# if !defined(_LIBCPP_VERSION)
80# ifndef __cpp_lib_formatters
81# error "__cpp_lib_formatters should be defined in c++23"
82# endif
83# if __cpp_lib_formatters != 202302L
84# error "__cpp_lib_formatters should have the value 202302L in c++23"
85# endif
86# else // _LIBCPP_VERSION
87# ifdef __cpp_lib_formatters
88# error "__cpp_lib_formatters should not be defined because it is unimplemented in libc++!"
89# endif
90# endif
91
92# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
93# ifndef __cpp_lib_jthread
94# error "__cpp_lib_jthread should be defined in c++23"
95# endif
96# if __cpp_lib_jthread != 201911L
97# error "__cpp_lib_jthread should have the value 201911L in c++23"
98# endif
99# else
100# ifdef __cpp_lib_jthread
101# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
102# endif
103# endif
104
105#elif TEST_STD_VER > 23
106
107# if !defined(_LIBCPP_VERSION)
108# ifndef __cpp_lib_formatters
109# error "__cpp_lib_formatters should be defined in c++26"
110# endif
111# if __cpp_lib_formatters != 202302L
112# error "__cpp_lib_formatters should have the value 202302L in c++26"
113# endif
114# else // _LIBCPP_VERSION
115# ifdef __cpp_lib_formatters
116# error "__cpp_lib_formatters should not be defined because it is unimplemented in libc++!"
117# endif
118# endif
119
120# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)
121# ifndef __cpp_lib_jthread
122# error "__cpp_lib_jthread should be defined in c++26"
123# endif
124# if __cpp_lib_jthread != 201911L
125# error "__cpp_lib_jthread should have the value 201911L in c++26"
126# endif
127# else
128# ifdef __cpp_lib_jthread
129# error "__cpp_lib_jthread should not be defined when the requirement '!defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)' is not met!"
130# endif
131# endif
132
133#endif // TEST_STD_VER > 23
134
135

source code of libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp