159 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// WARNING: This test was generated by generate_feature_test_macro_components.py10// and should not be edited manually.11 12// <optional>13 14// Test the feature test macros defined by <optional>15 16// clang-format off17 18#include <optional>19#include "test_macros.h"20 21#if TEST_STD_VER < 1422 23# ifdef __cpp_lib_constrained_equality24# error "__cpp_lib_constrained_equality should not be defined before c++26"25# endif26 27# ifdef __cpp_lib_freestanding_optional28# error "__cpp_lib_freestanding_optional should not be defined before c++26"29# endif30 31# ifdef __cpp_lib_optional32# error "__cpp_lib_optional should not be defined before c++17"33# endif34 35# ifdef __cpp_lib_optional_range_support36# error "__cpp_lib_optional_range_support should not be defined before c++26"37# endif38 39#elif TEST_STD_VER == 1440 41# ifdef __cpp_lib_constrained_equality42# error "__cpp_lib_constrained_equality should not be defined before c++26"43# endif44 45# ifdef __cpp_lib_freestanding_optional46# error "__cpp_lib_freestanding_optional should not be defined before c++26"47# endif48 49# ifdef __cpp_lib_optional50# error "__cpp_lib_optional should not be defined before c++17"51# endif52 53# ifdef __cpp_lib_optional_range_support54# error "__cpp_lib_optional_range_support should not be defined before c++26"55# endif56 57#elif TEST_STD_VER == 1758 59# ifdef __cpp_lib_constrained_equality60# error "__cpp_lib_constrained_equality should not be defined before c++26"61# endif62 63# ifdef __cpp_lib_freestanding_optional64# error "__cpp_lib_freestanding_optional should not be defined before c++26"65# endif66 67# ifndef __cpp_lib_optional68# error "__cpp_lib_optional should be defined in c++17"69# endif70# if __cpp_lib_optional != 201606L71# error "__cpp_lib_optional should have the value 201606L in c++17"72# endif73 74# ifdef __cpp_lib_optional_range_support75# error "__cpp_lib_optional_range_support should not be defined before c++26"76# endif77 78#elif TEST_STD_VER == 2079 80# ifdef __cpp_lib_constrained_equality81# error "__cpp_lib_constrained_equality should not be defined before c++26"82# endif83 84# ifdef __cpp_lib_freestanding_optional85# error "__cpp_lib_freestanding_optional should not be defined before c++26"86# endif87 88# ifndef __cpp_lib_optional89# error "__cpp_lib_optional should be defined in c++20"90# endif91# if __cpp_lib_optional != 202106L92# error "__cpp_lib_optional should have the value 202106L in c++20"93# endif94 95# ifdef __cpp_lib_optional_range_support96# error "__cpp_lib_optional_range_support should not be defined before c++26"97# endif98 99#elif TEST_STD_VER == 23100 101# ifdef __cpp_lib_constrained_equality102# error "__cpp_lib_constrained_equality should not be defined before c++26"103# endif104 105# ifdef __cpp_lib_freestanding_optional106# error "__cpp_lib_freestanding_optional should not be defined before c++26"107# endif108 109# ifndef __cpp_lib_optional110# error "__cpp_lib_optional should be defined in c++23"111# endif112# if __cpp_lib_optional != 202110L113# error "__cpp_lib_optional should have the value 202110L in c++23"114# endif115 116# ifdef __cpp_lib_optional_range_support117# error "__cpp_lib_optional_range_support should not be defined before c++26"118# endif119 120#elif TEST_STD_VER > 23121 122# ifndef __cpp_lib_constrained_equality123# error "__cpp_lib_constrained_equality should be defined in c++26"124# endif125# if __cpp_lib_constrained_equality != 202411L126# error "__cpp_lib_constrained_equality should have the value 202411L in c++26"127# endif128 129# if !defined(_LIBCPP_VERSION)130# ifndef __cpp_lib_freestanding_optional131# error "__cpp_lib_freestanding_optional should be defined in c++26"132# endif133# if __cpp_lib_freestanding_optional != 202311L134# error "__cpp_lib_freestanding_optional should have the value 202311L in c++26"135# endif136# else137# ifdef __cpp_lib_freestanding_optional138# error "__cpp_lib_freestanding_optional should not be defined because it is unimplemented in libc++!"139# endif140# endif141 142# ifndef __cpp_lib_optional143# error "__cpp_lib_optional should be defined in c++26"144# endif145# if __cpp_lib_optional != 202506L146# error "__cpp_lib_optional should have the value 202506L in c++26"147# endif148 149# ifndef __cpp_lib_optional_range_support150# error "__cpp_lib_optional_range_support should be defined in c++26"151# endif152# if __cpp_lib_optional_range_support != 202406L153# error "__cpp_lib_optional_range_support should have the value 202406L in c++26"154# endif155 156#endif // TEST_STD_VER > 23157 158// clang-format on159