-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++] Fix P1206R7 feature test macros #90914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-libcxx Author: None (krzysdz) Changes
Ref:
Patch is 68.53 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/90914.diff 15 Files Affected:
diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index 3197d2cd1b271c..1032a9c338f455 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -322,6 +322,8 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_typeinfo`` ``202106L``
---------------------------------------------------------- -----------------
+ ``__cpp_lib_containers_ranges`` ``202202L``
+ ---------------------------------------------------------- -----------------
``__cpp_lib_expected`` ``202211L``
---------------------------------------------------------- -----------------
``__cpp_lib_format_path`` *unimplemented*
diff --git a/libcxx/include/version b/libcxx/include/version
index 0ed77345baa71d..eb5fd5c8057843 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -79,6 +79,10 @@ __cpp_lib_constexpr_utility 201811L <utility>
__cpp_lib_constexpr_vector 201907L <vector>
__cpp_lib_constrained_equality 202403L <optional> <tuple> <utility>
<variant>
+__cpp_lib_containers_ranges 202202L <deque> <forward_list> <list>
+ <map> <queue> <set>
+ <stack> <string> <unordered_map>
+ <unordered_set> <vector>
__cpp_lib_copyable_function 202306L <functional>
__cpp_lib_coroutine 201902L <coroutine>
__cpp_lib_debugging 202311L <debugging>
@@ -184,10 +188,7 @@ __cpp_lib_ranges_join_with 202202L <ranges>
__cpp_lib_ranges_repeat 202207L <ranges>
__cpp_lib_ranges_slide 202202L <ranges>
__cpp_lib_ranges_starts_ends_with 202106L <algorithm>
-__cpp_lib_ranges_to_container 202202L <deque> <forward_list> <list>
- <map> <queue> <ranges>
- <set> <stack> <string>
- <unordered_map> <unordered_set> <vector>
+__cpp_lib_ranges_to_container 202202L <ranges>
__cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility>
__cpp_lib_ratio 202306L <ratio>
__cpp_lib_raw_memory_algorithms 201606L <memory>
@@ -456,6 +457,7 @@ __cpp_lib_within_lifetime 202306L <type_traits>
# undef __cpp_lib_constexpr_memory
# define __cpp_lib_constexpr_memory 202202L
# define __cpp_lib_constexpr_typeinfo 202106L
+# define __cpp_lib_containers_ranges 202202L
# define __cpp_lib_expected 202211L
// # define __cpp_lib_format_path 202403L
# define __cpp_lib_format_ranges 202207L
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/deque.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/deque.version.compile.pass.cpp
index 720557f33e2a14..d0e4ac130c60eb 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/deque.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/deque.version.compile.pass.cpp
@@ -17,10 +17,10 @@
/* Constant Value
__cpp_lib_allocator_traits_is_always_equal 201411L [C++17]
+ __cpp_lib_containers_ranges 202202L [C++23]
__cpp_lib_default_template_type_for_algorithm_values 202403L [C++26]
__cpp_lib_erase_if 202002L [C++20]
__cpp_lib_nonmember_container_access 201411L [C++17]
- __cpp_lib_ranges_to_container 202202L [C++23]
*/
#include <deque>
@@ -32,6 +32,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -44,16 +48,16 @@
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 14
# ifdef __cpp_lib_allocator_traits_is_always_equal
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -66,10 +70,6 @@
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 17
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -79,6 +79,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++17"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -94,10 +98,6 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++17"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 20
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -107,6 +107,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++20"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -125,10 +129,6 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++20"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 23
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -138,6 +138,13 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++23"
# endif
+# ifndef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should be defined in c++23"
+# endif
+# if __cpp_lib_containers_ranges != 202202L
+# error "__cpp_lib_containers_ranges should have the value 202202L in c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -156,13 +163,6 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++23"
# endif
-# ifndef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should be defined in c++23"
-# endif
-# if __cpp_lib_ranges_to_container != 202202L
-# error "__cpp_lib_ranges_to_container should have the value 202202L in c++23"
-# endif
-
#elif TEST_STD_VER > 23
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -172,6 +172,13 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++26"
# endif
+# ifndef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should be defined in c++26"
+# endif
+# if __cpp_lib_containers_ranges != 202202L
+# error "__cpp_lib_containers_ranges should have the value 202202L in c++26"
+# endif
+
# if !defined(_LIBCPP_VERSION)
# ifndef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should be defined in c++26"
@@ -199,12 +206,5 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++26"
# endif
-# ifndef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should be defined in c++26"
-# endif
-# if __cpp_lib_ranges_to_container != 202202L
-# error "__cpp_lib_ranges_to_container should have the value 202202L in c++26"
-# endif
-
#endif // TEST_STD_VER > 23
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/forward_list.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/forward_list.version.compile.pass.cpp
index 9305cf0c54b959..bcb606451b27f6 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/forward_list.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/forward_list.version.compile.pass.cpp
@@ -17,12 +17,12 @@
/* Constant Value
__cpp_lib_allocator_traits_is_always_equal 201411L [C++17]
+ __cpp_lib_containers_ranges 202202L [C++23]
__cpp_lib_default_template_type_for_algorithm_values 202403L [C++26]
__cpp_lib_erase_if 202002L [C++20]
__cpp_lib_incomplete_container_elements 201505L [C++17]
__cpp_lib_list_remove_return_type 201806L [C++20]
__cpp_lib_nonmember_container_access 201411L [C++17]
- __cpp_lib_ranges_to_container 202202L [C++23]
*/
#include <forward_list>
@@ -34,6 +34,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -54,16 +58,16 @@
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 14
# ifdef __cpp_lib_allocator_traits_is_always_equal
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -84,10 +88,6 @@
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 17
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -97,6 +97,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++17"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -123,10 +127,6 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++17"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 20
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -136,6 +136,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++20"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -168,10 +172,6 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++20"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 23
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -181,6 +181,13 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++23"
# endif
+# ifndef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should be defined in c++23"
+# endif
+# if __cpp_lib_containers_ranges != 202202L
+# error "__cpp_lib_containers_ranges should have the value 202202L in c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -213,13 +220,6 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++23"
# endif
-# ifndef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should be defined in c++23"
-# endif
-# if __cpp_lib_ranges_to_container != 202202L
-# error "__cpp_lib_ranges_to_container should have the value 202202L in c++23"
-# endif
-
#elif TEST_STD_VER > 23
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -229,6 +229,13 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++26"
# endif
+# ifndef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should be defined in c++26"
+# endif
+# if __cpp_lib_containers_ranges != 202202L
+# error "__cpp_lib_containers_ranges should have the value 202202L in c++26"
+# endif
+
# if !defined(_LIBCPP_VERSION)
# ifndef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should be defined in c++26"
@@ -270,12 +277,5 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++26"
# endif
-# ifndef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should be defined in c++26"
-# endif
-# if __cpp_lib_ranges_to_container != 202202L
-# error "__cpp_lib_ranges_to_container should have the value 202202L in c++26"
-# endif
-
#endif // TEST_STD_VER > 23
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/list.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/list.version.compile.pass.cpp
index 12225612b80d80..9cd3c3bc941c08 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/list.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/list.version.compile.pass.cpp
@@ -17,12 +17,12 @@
/* Constant Value
__cpp_lib_allocator_traits_is_always_equal 201411L [C++17]
+ __cpp_lib_containers_ranges 202202L [C++23]
__cpp_lib_default_template_type_for_algorithm_values 202403L [C++26]
__cpp_lib_erase_if 202002L [C++20]
__cpp_lib_incomplete_container_elements 201505L [C++17]
__cpp_lib_list_remove_return_type 201806L [C++20]
__cpp_lib_nonmember_container_access 201411L [C++17]
- __cpp_lib_ranges_to_container 202202L [C++23]
*/
#include <list>
@@ -34,6 +34,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -54,16 +58,16 @@
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 14
# ifdef __cpp_lib_allocator_traits_is_always_equal
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -84,10 +88,6 @@
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 17
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -97,6 +97,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++17"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -123,10 +127,6 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++17"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 20
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -136,6 +136,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++20"
# endif
+# ifdef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should not be defined before c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -168,10 +172,6 @@
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++20"
# endif
-# ifdef __cpp_lib_ranges_to_container
-# error "__cpp_lib_ranges_to_container should not be defined before c++23"
-# endif
-
#elif TEST_STD_VER == 23
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -181,6 +181,13 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++23"
# endif
+# ifndef __cpp_lib_containers_ranges
+# error "__cpp_lib_containers_ranges should be defined in c++23"
+# endif
+# if __cpp_lib_containers_ranges != 202202L
+# error "__cpp_lib_containers_ranges should have the value 202202L in c++23"
+# endif
+
# ifdef __cpp_lib_default_template_type_for_algorithm_values
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
# endif
@@ -213,13 +220,6 @@
# e...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! LGTM!
|
- Add missing `__cpp_lib_containers_ranges` feature test macro - Constrain `__cpp_lib_ranges_to_container` to the `<ranges>` header, since the standard does not list it in containers' headers
e30fc3d
to
282f0c5
Compare
Amended to use my real e-mail address and rebased. |
@krzysdz Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested Please check whether problems have been caused by your change specifically, as How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
/cherry-pick 028f1b0 |
Error: Command failed due to missing milestone. |
Sorry I missed this before. The last 18.1.x planned release has been released. @tstellar do you still accept PRs for LLVM 18? |
@mordante Probably not, but you can add it to the milestone just in case we do happen to do another release. |
__cpp_lib_containers_ranges
feature test macro__cpp_lib_ranges_to_container
to the<ranges>
header, since the standard does not list it in containers' headersRef: