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 // <variant>
15 
16 // Test the feature test macros defined by <variant>
17 
18 /*  Constant                          Value
19     __cpp_lib_constrained_equality    202403L [C++26]
20     __cpp_lib_freestanding_variant    202311L [C++26]
21     __cpp_lib_variant                 202102L [C++17]
22                                       202106L [C++20]
23                                       202306L [C++26]
24 */
25 
26 #include <variant>
27 #include "test_macros.h"
28 
29 #if TEST_STD_VER < 14
30 
31 # ifdef __cpp_lib_constrained_equality
32 #   error "__cpp_lib_constrained_equality should not be defined before c++26"
33 # endif
34 
35 # ifdef __cpp_lib_freestanding_variant
36 #   error "__cpp_lib_freestanding_variant should not be defined before c++26"
37 # endif
38 
39 # ifdef __cpp_lib_variant
40 #   error "__cpp_lib_variant should not be defined before c++17"
41 # endif
42 
43 #elif TEST_STD_VER == 14
44 
45 # ifdef __cpp_lib_constrained_equality
46 #   error "__cpp_lib_constrained_equality should not be defined before c++26"
47 # endif
48 
49 # ifdef __cpp_lib_freestanding_variant
50 #   error "__cpp_lib_freestanding_variant should not be defined before c++26"
51 # endif
52 
53 # ifdef __cpp_lib_variant
54 #   error "__cpp_lib_variant should not be defined before c++17"
55 # endif
56 
57 #elif TEST_STD_VER == 17
58 
59 # ifdef __cpp_lib_constrained_equality
60 #   error "__cpp_lib_constrained_equality should not be defined before c++26"
61 # endif
62 
63 # ifdef __cpp_lib_freestanding_variant
64 #   error "__cpp_lib_freestanding_variant should not be defined before c++26"
65 # endif
66 
67 # ifndef __cpp_lib_variant
68 #   error "__cpp_lib_variant should be defined in c++17"
69 # endif
70 # if __cpp_lib_variant != 202102L
71 #   error "__cpp_lib_variant should have the value 202102L in c++17"
72 # endif
73 
74 #elif TEST_STD_VER == 20
75 
76 # ifdef __cpp_lib_constrained_equality
77 #   error "__cpp_lib_constrained_equality should not be defined before c++26"
78 # endif
79 
80 # ifdef __cpp_lib_freestanding_variant
81 #   error "__cpp_lib_freestanding_variant should not be defined before c++26"
82 # endif
83 
84 # ifndef __cpp_lib_variant
85 #   error "__cpp_lib_variant should be defined in c++20"
86 # endif
87 # if __cpp_lib_variant != 202106L
88 #   error "__cpp_lib_variant should have the value 202106L in c++20"
89 # endif
90 
91 #elif TEST_STD_VER == 23
92 
93 # ifdef __cpp_lib_constrained_equality
94 #   error "__cpp_lib_constrained_equality should not be defined before c++26"
95 # endif
96 
97 # ifdef __cpp_lib_freestanding_variant
98 #   error "__cpp_lib_freestanding_variant should not be defined before c++26"
99 # endif
100 
101 # ifndef __cpp_lib_variant
102 #   error "__cpp_lib_variant should be defined in c++23"
103 # endif
104 # if __cpp_lib_variant != 202106L
105 #   error "__cpp_lib_variant should have the value 202106L in c++23"
106 # endif
107 
108 #elif TEST_STD_VER > 23
109 
110 # if !defined(_LIBCPP_VERSION)
111 #   ifndef __cpp_lib_constrained_equality
112 #     error "__cpp_lib_constrained_equality should be defined in c++26"
113 #   endif
114 #   if __cpp_lib_constrained_equality != 202403L
115 #     error "__cpp_lib_constrained_equality should have the value 202403L in c++26"
116 #   endif
117 # else // _LIBCPP_VERSION
118 #   ifdef __cpp_lib_constrained_equality
119 #     error "__cpp_lib_constrained_equality should not be defined because it is unimplemented in libc++!"
120 #   endif
121 # endif
122 
123 # if !defined(_LIBCPP_VERSION)
124 #   ifndef __cpp_lib_freestanding_variant
125 #     error "__cpp_lib_freestanding_variant should be defined in c++26"
126 #   endif
127 #   if __cpp_lib_freestanding_variant != 202311L
128 #     error "__cpp_lib_freestanding_variant should have the value 202311L in c++26"
129 #   endif
130 # else // _LIBCPP_VERSION
131 #   ifdef __cpp_lib_freestanding_variant
132 #     error "__cpp_lib_freestanding_variant should not be defined because it is unimplemented in libc++!"
133 #   endif
134 # endif
135 
136 # ifndef __cpp_lib_variant
137 #   error "__cpp_lib_variant should be defined in c++26"
138 # endif
139 # if __cpp_lib_variant != 202306L
140 #   error "__cpp_lib_variant should have the value 202306L in c++26"
141 # endif
142 
143 #endif // TEST_STD_VER > 23
144 
145