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