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 // <string_view>
15 
16 // Test the feature test macros defined by <string_view>
17 
18 /*  Constant                           Value
19     __cpp_lib_char8_t                  201907L [C++20]
20     __cpp_lib_constexpr_string_view    201811L [C++20]
21     __cpp_lib_starts_ends_with         201711L [C++20]
22     __cpp_lib_string_contains          202011L [C++2b]
23     __cpp_lib_string_view              201606L [C++17]
24                                        201803L [C++20]
25 */
26 
27 #include <string_view>
28 #include "test_macros.h"
29 
30 #if TEST_STD_VER < 14
31 
32 # ifdef __cpp_lib_char8_t
33 #   error "__cpp_lib_char8_t should not be defined before c++20"
34 # endif
35 
36 # ifdef __cpp_lib_constexpr_string_view
37 #   error "__cpp_lib_constexpr_string_view should not be defined before c++20"
38 # endif
39 
40 # ifdef __cpp_lib_starts_ends_with
41 #   error "__cpp_lib_starts_ends_with should not be defined before c++20"
42 # endif
43 
44 # ifdef __cpp_lib_string_contains
45 #   error "__cpp_lib_string_contains should not be defined before c++2b"
46 # endif
47 
48 # ifdef __cpp_lib_string_view
49 #   error "__cpp_lib_string_view should not be defined before c++17"
50 # endif
51 
52 #elif TEST_STD_VER == 14
53 
54 # ifdef __cpp_lib_char8_t
55 #   error "__cpp_lib_char8_t should not be defined before c++20"
56 # endif
57 
58 # ifdef __cpp_lib_constexpr_string_view
59 #   error "__cpp_lib_constexpr_string_view should not be defined before c++20"
60 # endif
61 
62 # ifdef __cpp_lib_starts_ends_with
63 #   error "__cpp_lib_starts_ends_with should not be defined before c++20"
64 # endif
65 
66 # ifdef __cpp_lib_string_contains
67 #   error "__cpp_lib_string_contains should not be defined before c++2b"
68 # endif
69 
70 # ifdef __cpp_lib_string_view
71 #   error "__cpp_lib_string_view should not be defined before c++17"
72 # endif
73 
74 #elif TEST_STD_VER == 17
75 
76 # ifdef __cpp_lib_char8_t
77 #   error "__cpp_lib_char8_t should not be defined before c++20"
78 # endif
79 
80 # ifdef __cpp_lib_constexpr_string_view
81 #   error "__cpp_lib_constexpr_string_view should not be defined before c++20"
82 # endif
83 
84 # ifdef __cpp_lib_starts_ends_with
85 #   error "__cpp_lib_starts_ends_with should not be defined before c++20"
86 # endif
87 
88 # ifdef __cpp_lib_string_contains
89 #   error "__cpp_lib_string_contains should not be defined before c++2b"
90 # endif
91 
92 # ifndef __cpp_lib_string_view
93 #   error "__cpp_lib_string_view should be defined in c++17"
94 # endif
95 # if __cpp_lib_string_view != 201606L
96 #   error "__cpp_lib_string_view should have the value 201606L in c++17"
97 # endif
98 
99 #elif TEST_STD_VER == 20
100 
101 # if defined(__cpp_char8_t)
102 #   ifndef __cpp_lib_char8_t
103 #     error "__cpp_lib_char8_t should be defined in c++20"
104 #   endif
105 #   if __cpp_lib_char8_t != 201907L
106 #     error "__cpp_lib_char8_t should have the value 201907L in c++20"
107 #   endif
108 # else
109 #   ifdef __cpp_lib_char8_t
110 #     error "__cpp_lib_char8_t should not be defined when defined(__cpp_char8_t) is not defined!"
111 #   endif
112 # endif
113 
114 # ifndef __cpp_lib_constexpr_string_view
115 #   error "__cpp_lib_constexpr_string_view should be defined in c++20"
116 # endif
117 # if __cpp_lib_constexpr_string_view != 201811L
118 #   error "__cpp_lib_constexpr_string_view should have the value 201811L in c++20"
119 # endif
120 
121 # ifndef __cpp_lib_starts_ends_with
122 #   error "__cpp_lib_starts_ends_with should be defined in c++20"
123 # endif
124 # if __cpp_lib_starts_ends_with != 201711L
125 #   error "__cpp_lib_starts_ends_with should have the value 201711L in c++20"
126 # endif
127 
128 # ifdef __cpp_lib_string_contains
129 #   error "__cpp_lib_string_contains should not be defined before c++2b"
130 # endif
131 
132 # ifndef __cpp_lib_string_view
133 #   error "__cpp_lib_string_view should be defined in c++20"
134 # endif
135 # if __cpp_lib_string_view != 201803L
136 #   error "__cpp_lib_string_view should have the value 201803L in c++20"
137 # endif
138 
139 #elif TEST_STD_VER > 20
140 
141 # if defined(__cpp_char8_t)
142 #   ifndef __cpp_lib_char8_t
143 #     error "__cpp_lib_char8_t should be defined in c++2b"
144 #   endif
145 #   if __cpp_lib_char8_t != 201907L
146 #     error "__cpp_lib_char8_t should have the value 201907L in c++2b"
147 #   endif
148 # else
149 #   ifdef __cpp_lib_char8_t
150 #     error "__cpp_lib_char8_t should not be defined when defined(__cpp_char8_t) is not defined!"
151 #   endif
152 # endif
153 
154 # ifndef __cpp_lib_constexpr_string_view
155 #   error "__cpp_lib_constexpr_string_view should be defined in c++2b"
156 # endif
157 # if __cpp_lib_constexpr_string_view != 201811L
158 #   error "__cpp_lib_constexpr_string_view should have the value 201811L in c++2b"
159 # endif
160 
161 # ifndef __cpp_lib_starts_ends_with
162 #   error "__cpp_lib_starts_ends_with should be defined in c++2b"
163 # endif
164 # if __cpp_lib_starts_ends_with != 201711L
165 #   error "__cpp_lib_starts_ends_with should have the value 201711L in c++2b"
166 # endif
167 
168 # ifndef __cpp_lib_string_contains
169 #   error "__cpp_lib_string_contains should be defined in c++2b"
170 # endif
171 # if __cpp_lib_string_contains != 202011L
172 #   error "__cpp_lib_string_contains should have the value 202011L in c++2b"
173 # endif
174 
175 # ifndef __cpp_lib_string_view
176 #   error "__cpp_lib_string_view should be defined in c++2b"
177 # endif
178 # if __cpp_lib_string_view != 201803L
179 #   error "__cpp_lib_string_view should have the value 201803L in c++2b"
180 # endif
181 
182 #endif // TEST_STD_VER > 20
183 
184