diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index 17b3476d2c869e..17d2da907692e8 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -436,6 +436,8 @@ Status ---------------------------------------------------------- ----------------- ``__cpp_lib_hazard_pointer`` *unimplemented* ---------------------------------------------------------- ----------------- + ``__cpp_lib_is_within_lifetime`` *unimplemented* + ---------------------------------------------------------- ----------------- ``__cpp_lib_linalg`` *unimplemented* ---------------------------------------------------------- ----------------- ``__cpp_lib_out_ptr`` *unimplemented* @@ -465,7 +467,5 @@ Status ``__cpp_lib_to_chars`` *unimplemented* ---------------------------------------------------------- ----------------- ``__cpp_lib_tuple_like`` *unimplemented* - ---------------------------------------------------------- ----------------- - ``__cpp_lib_within_lifetime`` *unimplemented* ========================================================== ================= diff --git a/libcxx/include/version b/libcxx/include/version index ba116957b033f5..69556d731f1cfc 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -143,6 +143,7 @@ __cpp_lib_is_null_pointer 201309L __cpp_lib_is_pointer_interconvertible 201907L __cpp_lib_is_scoped_enum 202011L __cpp_lib_is_swappable 201603L +__cpp_lib_is_within_lifetime 202306L __cpp_lib_jthread 201911L __cpp_lib_latch 201907L __cpp_lib_launder 201606L @@ -251,7 +252,6 @@ __cpp_lib_unreachable 202202L __cpp_lib_unwrap_ref 201811L __cpp_lib_variant 202102L __cpp_lib_void_t 201411L -__cpp_lib_within_lifetime 202306L */ @@ -520,6 +520,7 @@ __cpp_lib_within_lifetime 202306L // # define __cpp_lib_function_ref 202306L // # define __cpp_lib_generate_random 202403L // # define __cpp_lib_hazard_pointer 202306L +// # define __cpp_lib_is_within_lifetime 202306L // # define __cpp_lib_linalg 202311L # undef __cpp_lib_out_ptr // # define __cpp_lib_out_ptr 202311L @@ -538,7 +539,6 @@ __cpp_lib_within_lifetime 202306L // # define __cpp_lib_to_chars 202306L # undef __cpp_lib_tuple_like // # define __cpp_lib_tuple_like 202311L -// # define __cpp_lib_within_lifetime 202306L #endif // clang-format on diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp index b1dd76b98720d0..98277f832f5a04 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp @@ -30,6 +30,7 @@ __cpp_lib_is_pointer_interconvertible 201907L [C++20] __cpp_lib_is_scoped_enum 202011L [C++23] __cpp_lib_is_swappable 201603L [C++17] + __cpp_lib_is_within_lifetime 202306L [C++26] __cpp_lib_logical_traits 201510L [C++17] __cpp_lib_reference_from_temporary 202202L [C++23] __cpp_lib_remove_cvref 201711L [C++20] @@ -38,7 +39,6 @@ __cpp_lib_type_identity 201806L [C++20] __cpp_lib_type_trait_variable_templates 201510L [C++17] __cpp_lib_void_t 201411L [C++17] - __cpp_lib_within_lifetime 202306L [C++26] */ #include @@ -102,6 +102,10 @@ # error "__cpp_lib_is_swappable should not be defined before c++17" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # ifdef __cpp_lib_logical_traits # error "__cpp_lib_logical_traits should not be defined before c++17" # endif @@ -134,10 +138,6 @@ # error "__cpp_lib_void_t should not be defined before c++17" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER == 14 # ifdef __cpp_lib_bool_constant @@ -205,6 +205,10 @@ # error "__cpp_lib_is_swappable should not be defined before c++17" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # ifdef __cpp_lib_logical_traits # error "__cpp_lib_logical_traits should not be defined before c++17" # endif @@ -243,10 +247,6 @@ # error "__cpp_lib_void_t should not be defined before c++17" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER == 17 # ifndef __cpp_lib_bool_constant @@ -329,6 +329,10 @@ # error "__cpp_lib_is_swappable should have the value 201603L in c++17" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # ifndef __cpp_lib_logical_traits # error "__cpp_lib_logical_traits should be defined in c++17" # endif @@ -376,10 +380,6 @@ # error "__cpp_lib_void_t should have the value 201411L in c++17" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER == 20 # ifndef __cpp_lib_bool_constant @@ -489,6 +489,10 @@ # error "__cpp_lib_is_swappable should have the value 201603L in c++20" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # ifndef __cpp_lib_logical_traits # error "__cpp_lib_logical_traits should be defined in c++20" # endif @@ -542,10 +546,6 @@ # error "__cpp_lib_void_t should have the value 201411L in c++20" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER == 23 # ifndef __cpp_lib_bool_constant @@ -658,6 +658,10 @@ # error "__cpp_lib_is_swappable should have the value 201603L in c++23" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # ifndef __cpp_lib_logical_traits # error "__cpp_lib_logical_traits should be defined in c++23" # endif @@ -720,10 +724,6 @@ # error "__cpp_lib_void_t should have the value 201411L in c++23" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER > 23 # ifndef __cpp_lib_bool_constant @@ -836,6 +836,19 @@ # error "__cpp_lib_is_swappable should have the value 201603L in c++26" # endif +# if !defined(_LIBCPP_VERSION) +# ifndef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should be defined in c++26" +# endif +# if __cpp_lib_is_within_lifetime != 202306L +# error "__cpp_lib_is_within_lifetime should have the value 202306L in c++26" +# endif +# else // _LIBCPP_VERSION +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined because it is unimplemented in libc++!" +# endif +# endif + # ifndef __cpp_lib_logical_traits # error "__cpp_lib_logical_traits should be defined in c++26" # endif @@ -898,18 +911,5 @@ # error "__cpp_lib_void_t should have the value 201411L in c++26" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should be defined in c++26" -# endif -# if __cpp_lib_within_lifetime != 202306L -# error "__cpp_lib_within_lifetime should have the value 202306L in c++26" -# endif -# else // _LIBCPP_VERSION -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined because it is unimplemented in libc++!" -# endif -# endif - #endif // TEST_STD_VER > 23 diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp index d7035d7e5e3ad8..7829e06f90760b 100644 --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -130,6 +130,7 @@ __cpp_lib_is_pointer_interconvertible 201907L [C++20] __cpp_lib_is_scoped_enum 202011L [C++23] __cpp_lib_is_swappable 201603L [C++17] + __cpp_lib_is_within_lifetime 202306L [C++26] __cpp_lib_jthread 201911L [C++20] __cpp_lib_latch 201907L [C++20] __cpp_lib_launder 201606L [C++17] @@ -232,7 +233,6 @@ __cpp_lib_unwrap_ref 201811L [C++20] __cpp_lib_variant 202102L [C++17] __cpp_lib_void_t 201411L [C++17] - __cpp_lib_within_lifetime 202306L [C++26] */ #include @@ -680,6 +680,10 @@ # error "__cpp_lib_is_swappable should not be defined before c++17" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # ifdef __cpp_lib_jthread # error "__cpp_lib_jthread should not be defined before c++20" # endif @@ -1060,10 +1064,6 @@ # error "__cpp_lib_void_t should not be defined before c++17" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER == 14 # ifdef __cpp_lib_adaptor_iterator_pair_constructor @@ -1530,6 +1530,10 @@ # error "__cpp_lib_is_swappable should not be defined before c++17" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # ifdef __cpp_lib_jthread # error "__cpp_lib_jthread should not be defined before c++20" # endif @@ -1958,10 +1962,6 @@ # error "__cpp_lib_void_t should not be defined before c++17" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER == 17 # ifdef __cpp_lib_adaptor_iterator_pair_constructor @@ -2518,6 +2518,10 @@ # error "__cpp_lib_is_swappable should have the value 201603L in c++17" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # ifdef __cpp_lib_jthread # error "__cpp_lib_jthread should not be defined before c++20" # endif @@ -3054,10 +3058,6 @@ # error "__cpp_lib_void_t should have the value 201411L in c++17" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER == 20 # ifdef __cpp_lib_adaptor_iterator_pair_constructor @@ -3797,6 +3797,10 @@ # error "__cpp_lib_is_swappable should have the value 201603L in c++20" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC) # ifndef __cpp_lib_jthread # error "__cpp_lib_jthread should be defined in c++20" @@ -4438,10 +4442,6 @@ # error "__cpp_lib_void_t should have the value 201411L in c++20" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER == 23 # ifndef __cpp_lib_adaptor_iterator_pair_constructor @@ -5259,6 +5259,10 @@ # error "__cpp_lib_is_swappable should have the value 201603L in c++23" # endif +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined before c++26" +# endif + # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC) # ifndef __cpp_lib_jthread # error "__cpp_lib_jthread should be defined in c++23" @@ -6056,10 +6060,6 @@ # error "__cpp_lib_void_t should have the value 201411L in c++23" # endif -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined before c++26" -# endif - #elif TEST_STD_VER > 23 # ifndef __cpp_lib_adaptor_iterator_pair_constructor @@ -7042,6 +7042,19 @@ # error "__cpp_lib_is_swappable should have the value 201603L in c++26" # endif +# if !defined(_LIBCPP_VERSION) +# ifndef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should be defined in c++26" +# endif +# if __cpp_lib_is_within_lifetime != 202306L +# error "__cpp_lib_is_within_lifetime should have the value 202306L in c++26" +# endif +# else // _LIBCPP_VERSION +# ifdef __cpp_lib_is_within_lifetime +# error "__cpp_lib_is_within_lifetime should not be defined because it is unimplemented in libc++!" +# endif +# endif + # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC) # ifndef __cpp_lib_jthread # error "__cpp_lib_jthread should be defined in c++26" @@ -7911,18 +7924,5 @@ # error "__cpp_lib_void_t should have the value 201411L in c++26" # endif -# if !defined(_LIBCPP_VERSION) -# ifndef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should be defined in c++26" -# endif -# if __cpp_lib_within_lifetime != 202306L -# error "__cpp_lib_within_lifetime should have the value 202306L in c++26" -# endif -# else // _LIBCPP_VERSION -# ifdef __cpp_lib_within_lifetime -# error "__cpp_lib_within_lifetime should not be defined because it is unimplemented in libc++!" -# endif -# endif - #endif // TEST_STD_VER > 23 diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index d0171c84acbc32..b04cb4f5115547 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -767,6 +767,16 @@ def add_version_header(tc): "values": {"c++17": 201603}, "headers": ["type_traits"], }, + { + "name": "__cpp_lib_is_within_lifetime", + # Note this name was changed from "__cpp_lib_within_lifetime" when the paper was adopted + # https://github.com/cplusplus/draft/commit/0facada4cadd97e1ba15bfaea76a804f1dc5c309 + "values": { + "c++26": 202306 # P2641R4 Checking if a union alternative is active + }, + "headers": ["type_traits"], + "unimplemented": True, + }, { "name": "__cpp_lib_jthread", "values": {"c++20": 201911}, @@ -1342,14 +1352,6 @@ def add_version_header(tc): "values": {"c++17": 201411}, "headers": ["type_traits"], }, - { - "name": "__cpp_lib_within_lifetime", - "values": { - "c++26": 202306 # P2641R4 Checking if a union alternative is active - }, - "headers": ["type_traits"], - "unimplemented": True, - }, ] ]