Skip to content

Commit 028f1b0

Browse files
authored
[libc++] Fix P1206R7 feature test macros (#90914)
- 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 Ref: - https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1206r7.pdf#section.18 - https://eel.is/c++draft/support.limits#lib:__cpp_lib_containers_ranges - https://eel.is/c++draft/support.limits#lib:__cpp_lib_ranges_to_container
1 parent cb015b9 commit 028f1b0

15 files changed

+370
-331
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ Status
322322
---------------------------------------------------------- -----------------
323323
``__cpp_lib_constexpr_typeinfo`` ``202106L``
324324
---------------------------------------------------------- -----------------
325+
``__cpp_lib_containers_ranges`` ``202202L``
326+
---------------------------------------------------------- -----------------
325327
``__cpp_lib_expected`` ``202211L``
326328
---------------------------------------------------------- -----------------
327329
``__cpp_lib_format_path`` *unimplemented*

libcxx/include/version

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ __cpp_lib_constexpr_utility 201811L <utility>
7979
__cpp_lib_constexpr_vector 201907L <vector>
8080
__cpp_lib_constrained_equality 202403L <optional> <tuple> <utility>
8181
<variant>
82+
__cpp_lib_containers_ranges 202202L <deque> <forward_list> <list>
83+
<map> <queue> <set>
84+
<stack> <string> <unordered_map>
85+
<unordered_set> <vector>
8286
__cpp_lib_copyable_function 202306L <functional>
8387
__cpp_lib_coroutine 201902L <coroutine>
8488
__cpp_lib_debugging 202311L <debugging>
@@ -184,10 +188,7 @@ __cpp_lib_ranges_join_with 202202L <ranges>
184188
__cpp_lib_ranges_repeat 202207L <ranges>
185189
__cpp_lib_ranges_slide 202202L <ranges>
186190
__cpp_lib_ranges_starts_ends_with 202106L <algorithm>
187-
__cpp_lib_ranges_to_container 202202L <deque> <forward_list> <list>
188-
<map> <queue> <ranges>
189-
<set> <stack> <string>
190-
<unordered_map> <unordered_set> <vector>
191+
__cpp_lib_ranges_to_container 202202L <ranges>
191192
__cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility>
192193
__cpp_lib_ratio 202306L <ratio>
193194
__cpp_lib_raw_memory_algorithms 201606L <memory>
@@ -456,6 +457,7 @@ __cpp_lib_within_lifetime 202306L <type_traits>
456457
# undef __cpp_lib_constexpr_memory
457458
# define __cpp_lib_constexpr_memory 202202L
458459
# define __cpp_lib_constexpr_typeinfo 202106L
460+
# define __cpp_lib_containers_ranges 202202L
459461
# define __cpp_lib_expected 202211L
460462
// # define __cpp_lib_format_path 202403L
461463
# define __cpp_lib_format_ranges 202207L

libcxx/test/std/language.support/support.limits/support.limits.general/deque.version.compile.pass.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
/* Constant Value
1919
__cpp_lib_allocator_traits_is_always_equal 201411L [C++17]
20+
__cpp_lib_containers_ranges 202202L [C++23]
2021
__cpp_lib_default_template_type_for_algorithm_values 202403L [C++26]
2122
__cpp_lib_erase_if 202002L [C++20]
2223
__cpp_lib_nonmember_container_access 201411L [C++17]
23-
__cpp_lib_ranges_to_container 202202L [C++23]
2424
*/
2525

2626
#include <deque>
@@ -32,6 +32,10 @@
3232
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
3333
# endif
3434

35+
# ifdef __cpp_lib_containers_ranges
36+
# error "__cpp_lib_containers_ranges should not be defined before c++23"
37+
# endif
38+
3539
# ifdef __cpp_lib_default_template_type_for_algorithm_values
3640
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
3741
# endif
@@ -44,16 +48,16 @@
4448
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
4549
# endif
4650

47-
# ifdef __cpp_lib_ranges_to_container
48-
# error "__cpp_lib_ranges_to_container should not be defined before c++23"
49-
# endif
50-
5151
#elif TEST_STD_VER == 14
5252

5353
# ifdef __cpp_lib_allocator_traits_is_always_equal
5454
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
5555
# endif
5656

57+
# ifdef __cpp_lib_containers_ranges
58+
# error "__cpp_lib_containers_ranges should not be defined before c++23"
59+
# endif
60+
5761
# ifdef __cpp_lib_default_template_type_for_algorithm_values
5862
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
5963
# endif
@@ -66,10 +70,6 @@
6670
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
6771
# endif
6872

69-
# ifdef __cpp_lib_ranges_to_container
70-
# error "__cpp_lib_ranges_to_container should not be defined before c++23"
71-
# endif
72-
7373
#elif TEST_STD_VER == 17
7474

7575
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -79,6 +79,10 @@
7979
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++17"
8080
# endif
8181

82+
# ifdef __cpp_lib_containers_ranges
83+
# error "__cpp_lib_containers_ranges should not be defined before c++23"
84+
# endif
85+
8286
# ifdef __cpp_lib_default_template_type_for_algorithm_values
8387
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
8488
# endif
@@ -94,10 +98,6 @@
9498
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++17"
9599
# endif
96100

97-
# ifdef __cpp_lib_ranges_to_container
98-
# error "__cpp_lib_ranges_to_container should not be defined before c++23"
99-
# endif
100-
101101
#elif TEST_STD_VER == 20
102102

103103
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -107,6 +107,10 @@
107107
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++20"
108108
# endif
109109

110+
# ifdef __cpp_lib_containers_ranges
111+
# error "__cpp_lib_containers_ranges should not be defined before c++23"
112+
# endif
113+
110114
# ifdef __cpp_lib_default_template_type_for_algorithm_values
111115
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
112116
# endif
@@ -125,10 +129,6 @@
125129
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++20"
126130
# endif
127131

128-
# ifdef __cpp_lib_ranges_to_container
129-
# error "__cpp_lib_ranges_to_container should not be defined before c++23"
130-
# endif
131-
132132
#elif TEST_STD_VER == 23
133133

134134
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -138,6 +138,13 @@
138138
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++23"
139139
# endif
140140

141+
# ifndef __cpp_lib_containers_ranges
142+
# error "__cpp_lib_containers_ranges should be defined in c++23"
143+
# endif
144+
# if __cpp_lib_containers_ranges != 202202L
145+
# error "__cpp_lib_containers_ranges should have the value 202202L in c++23"
146+
# endif
147+
141148
# ifdef __cpp_lib_default_template_type_for_algorithm_values
142149
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
143150
# endif
@@ -156,13 +163,6 @@
156163
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++23"
157164
# endif
158165

159-
# ifndef __cpp_lib_ranges_to_container
160-
# error "__cpp_lib_ranges_to_container should be defined in c++23"
161-
# endif
162-
# if __cpp_lib_ranges_to_container != 202202L
163-
# error "__cpp_lib_ranges_to_container should have the value 202202L in c++23"
164-
# endif
165-
166166
#elif TEST_STD_VER > 23
167167

168168
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -172,6 +172,13 @@
172172
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++26"
173173
# endif
174174

175+
# ifndef __cpp_lib_containers_ranges
176+
# error "__cpp_lib_containers_ranges should be defined in c++26"
177+
# endif
178+
# if __cpp_lib_containers_ranges != 202202L
179+
# error "__cpp_lib_containers_ranges should have the value 202202L in c++26"
180+
# endif
181+
175182
# if !defined(_LIBCPP_VERSION)
176183
# ifndef __cpp_lib_default_template_type_for_algorithm_values
177184
# error "__cpp_lib_default_template_type_for_algorithm_values should be defined in c++26"
@@ -199,12 +206,5 @@
199206
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++26"
200207
# endif
201208

202-
# ifndef __cpp_lib_ranges_to_container
203-
# error "__cpp_lib_ranges_to_container should be defined in c++26"
204-
# endif
205-
# if __cpp_lib_ranges_to_container != 202202L
206-
# error "__cpp_lib_ranges_to_container should have the value 202202L in c++26"
207-
# endif
208-
209209
#endif // TEST_STD_VER > 23
210210

libcxx/test/std/language.support/support.limits/support.limits.general/forward_list.version.compile.pass.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
/* Constant Value
1919
__cpp_lib_allocator_traits_is_always_equal 201411L [C++17]
20+
__cpp_lib_containers_ranges 202202L [C++23]
2021
__cpp_lib_default_template_type_for_algorithm_values 202403L [C++26]
2122
__cpp_lib_erase_if 202002L [C++20]
2223
__cpp_lib_incomplete_container_elements 201505L [C++17]
2324
__cpp_lib_list_remove_return_type 201806L [C++20]
2425
__cpp_lib_nonmember_container_access 201411L [C++17]
25-
__cpp_lib_ranges_to_container 202202L [C++23]
2626
*/
2727

2828
#include <forward_list>
@@ -34,6 +34,10 @@
3434
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
3535
# endif
3636

37+
# ifdef __cpp_lib_containers_ranges
38+
# error "__cpp_lib_containers_ranges should not be defined before c++23"
39+
# endif
40+
3741
# ifdef __cpp_lib_default_template_type_for_algorithm_values
3842
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
3943
# endif
@@ -54,16 +58,16 @@
5458
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
5559
# endif
5660

57-
# ifdef __cpp_lib_ranges_to_container
58-
# error "__cpp_lib_ranges_to_container should not be defined before c++23"
59-
# endif
60-
6161
#elif TEST_STD_VER == 14
6262

6363
# ifdef __cpp_lib_allocator_traits_is_always_equal
6464
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
6565
# endif
6666

67+
# ifdef __cpp_lib_containers_ranges
68+
# error "__cpp_lib_containers_ranges should not be defined before c++23"
69+
# endif
70+
6771
# ifdef __cpp_lib_default_template_type_for_algorithm_values
6872
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
6973
# endif
@@ -84,10 +88,6 @@
8488
# error "__cpp_lib_nonmember_container_access should not be defined before c++17"
8589
# endif
8690

87-
# ifdef __cpp_lib_ranges_to_container
88-
# error "__cpp_lib_ranges_to_container should not be defined before c++23"
89-
# endif
90-
9191
#elif TEST_STD_VER == 17
9292

9393
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -97,6 +97,10 @@
9797
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++17"
9898
# endif
9999

100+
# ifdef __cpp_lib_containers_ranges
101+
# error "__cpp_lib_containers_ranges should not be defined before c++23"
102+
# endif
103+
100104
# ifdef __cpp_lib_default_template_type_for_algorithm_values
101105
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
102106
# endif
@@ -123,10 +127,6 @@
123127
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++17"
124128
# endif
125129

126-
# ifdef __cpp_lib_ranges_to_container
127-
# error "__cpp_lib_ranges_to_container should not be defined before c++23"
128-
# endif
129-
130130
#elif TEST_STD_VER == 20
131131

132132
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -136,6 +136,10 @@
136136
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++20"
137137
# endif
138138

139+
# ifdef __cpp_lib_containers_ranges
140+
# error "__cpp_lib_containers_ranges should not be defined before c++23"
141+
# endif
142+
139143
# ifdef __cpp_lib_default_template_type_for_algorithm_values
140144
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
141145
# endif
@@ -168,10 +172,6 @@
168172
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++20"
169173
# endif
170174

171-
# ifdef __cpp_lib_ranges_to_container
172-
# error "__cpp_lib_ranges_to_container should not be defined before c++23"
173-
# endif
174-
175175
#elif TEST_STD_VER == 23
176176

177177
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -181,6 +181,13 @@
181181
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++23"
182182
# endif
183183

184+
# ifndef __cpp_lib_containers_ranges
185+
# error "__cpp_lib_containers_ranges should be defined in c++23"
186+
# endif
187+
# if __cpp_lib_containers_ranges != 202202L
188+
# error "__cpp_lib_containers_ranges should have the value 202202L in c++23"
189+
# endif
190+
184191
# ifdef __cpp_lib_default_template_type_for_algorithm_values
185192
# error "__cpp_lib_default_template_type_for_algorithm_values should not be defined before c++26"
186193
# endif
@@ -213,13 +220,6 @@
213220
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++23"
214221
# endif
215222

216-
# ifndef __cpp_lib_ranges_to_container
217-
# error "__cpp_lib_ranges_to_container should be defined in c++23"
218-
# endif
219-
# if __cpp_lib_ranges_to_container != 202202L
220-
# error "__cpp_lib_ranges_to_container should have the value 202202L in c++23"
221-
# endif
222-
223223
#elif TEST_STD_VER > 23
224224

225225
# ifndef __cpp_lib_allocator_traits_is_always_equal
@@ -229,6 +229,13 @@
229229
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++26"
230230
# endif
231231

232+
# ifndef __cpp_lib_containers_ranges
233+
# error "__cpp_lib_containers_ranges should be defined in c++26"
234+
# endif
235+
# if __cpp_lib_containers_ranges != 202202L
236+
# error "__cpp_lib_containers_ranges should have the value 202202L in c++26"
237+
# endif
238+
232239
# if !defined(_LIBCPP_VERSION)
233240
# ifndef __cpp_lib_default_template_type_for_algorithm_values
234241
# error "__cpp_lib_default_template_type_for_algorithm_values should be defined in c++26"
@@ -270,12 +277,5 @@
270277
# error "__cpp_lib_nonmember_container_access should have the value 201411L in c++26"
271278
# endif
272279

273-
# ifndef __cpp_lib_ranges_to_container
274-
# error "__cpp_lib_ranges_to_container should be defined in c++26"
275-
# endif
276-
# if __cpp_lib_ranges_to_container != 202202L
277-
# error "__cpp_lib_ranges_to_container should have the value 202202L in c++26"
278-
# endif
279-
280280
#endif // TEST_STD_VER > 23
281281

0 commit comments

Comments
 (0)