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