Skip to content

Commit 7d7d475

Browse files
[libc++] Set feature test macros __cpp_lib_ranges_contains and__cpp_lib_ranges_starts_ends_with (#81816)
ranges::contains: fdd089b ranges::starts_with: 2051755 ranges::ends_with: 0218ea4 Co-authored-by: Louis Dionne <[email protected]>
1 parent d1924f0 commit 7d7d475

File tree

7 files changed

+97
-50
lines changed

7 files changed

+97
-50
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ Status
354354
--------------------------------------------------- -----------------
355355
``__cpp_lib_ranges_chunk_by`` ``202202L``
356356
--------------------------------------------------- -----------------
357+
``__cpp_lib_ranges_contains`` ``202207L``
358+
--------------------------------------------------- -----------------
357359
``__cpp_lib_ranges_iota`` *unimplemented*
358360
--------------------------------------------------- -----------------
359361
``__cpp_lib_ranges_join_with`` *unimplemented*
@@ -362,7 +364,7 @@ Status
362364
--------------------------------------------------- -----------------
363365
``__cpp_lib_ranges_slide`` *unimplemented*
364366
--------------------------------------------------- -----------------
365-
``__cpp_lib_ranges_starts_ends_with`` *unimplemented*
367+
``__cpp_lib_ranges_starts_ends_with`` ``202106L``
366368
--------------------------------------------------- -----------------
367369
``__cpp_lib_ranges_to_container`` ``202202L``
368370
--------------------------------------------------- -----------------

libcxx/docs/ReleaseNotes/19.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ Implemented Papers
4141
- P2637R3 - Member ``visit``
4242
- P2652R2 - Disallow User Specialization of ``allocator_traits``
4343
- P2819R2 - Add ``tuple`` protocol to ``complex``
44-
44+
- P2302R4 - ``std::ranges::contains``
45+
- P1659R3 - ``std::ranges::starts_with`` and ``std::ranges::ends_with``
4546

4647
Improvements and New Features
4748
-----------------------------

libcxx/docs/Status/Cxx23Papers.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"`P1328R1 <https://wg21.link/P1328R1>`__","LWG","Making std::type_info::operator== constexpr","June 2021","|Complete|","17.0"
1818
"`P1425R4 <https://wg21.link/P1425R4>`__","LWG","Iterators pair constructors for stack and queue","June 2021","|Complete|","14.0","|ranges|"
1919
"`P1518R2 <https://wg21.link/P1518R2>`__","LWG","Stop overconstraining allocators in container deduction guides","June 2021","|Complete|","13.0"
20-
"`P1659R3 <https://wg21.link/P1659R3>`__","LWG","starts_with and ends_with","June 2021","","","|ranges|"
20+
"`P1659R3 <https://wg21.link/P1659R3>`__","LWG","starts_with and ends_with","June 2021","|Complete|","19.0","|ranges|"
2121
"`P1951R1 <https://wg21.link/P1951R1>`__","LWG","Default Arguments for pair Forwarding Constructor","June 2021","|Complete|","14.0"
2222
"`P1989R2 <https://wg21.link/P1989R2>`__","LWG","Range constructor for std::string_view","June 2021","|Complete|","14.0","|ranges|"
2323
"`P2136R3 <https://wg21.link/P2136R3>`__","LWG","invoke_r","June 2021","|Complete|","17.0"
@@ -64,7 +64,7 @@
6464
"`P2278R4 <https://wg21.link/P2278R4>`__","LWG","``cbegin`` should always return a constant iterator","July 2022","","","|ranges|"
6565
"`P2286R8 <https://wg21.link/P2286R8>`__","LWG","Formatting Ranges","July 2022","|Complete|","16.0","|format| |ranges|"
6666
"`P2291R3 <https://wg21.link/P2291R3>`__","LWG","Add Constexpr Modifiers to Functions ``to_chars`` and ``from_chars`` for Integral Types in ``<charconv>`` Header","July 2022","|Complete|","16.0"
67-
"`P2302R4 <https://wg21.link/P2302R4>`__","LWG","``std::ranges::contains``","July 2022","","","|ranges|"
67+
"`P2302R4 <https://wg21.link/P2302R4>`__","LWG","``std::ranges::contains``","July 2022","|Complete|","19.0","|ranges|"
6868
"`P2322R6 <https://wg21.link/P2322R6>`__","LWG","``ranges::fold``","July 2022","","","|ranges|"
6969
"`P2374R4 <https://wg21.link/P2374R4>`__","LWG","``views::cartesian_product``","July 2022","","","|ranges|"
7070
"`P2404R3 <https://wg21.link/P2404R3>`__","LWG","Move-only types for ``equality_comparable_with``, ``totally_ordered_with``, and ``three_way_comparable_with``","July 2022","",""

libcxx/include/version

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ __cpp_lib_ranges_as_const 202207L <ranges>
170170
__cpp_lib_ranges_as_rvalue 202207L <ranges>
171171
__cpp_lib_ranges_chunk 202202L <ranges>
172172
__cpp_lib_ranges_chunk_by 202202L <ranges>
173+
__cpp_lib_ranges_contains 202207L <algorithm>
173174
__cpp_lib_ranges_iota 202202L <numeric>
174175
__cpp_lib_ranges_join_with 202202L <ranges>
175176
__cpp_lib_ranges_repeat 202207L <ranges>
@@ -463,11 +464,12 @@ __cpp_lib_within_lifetime 202306L <type_traits>
463464
# define __cpp_lib_ranges_as_rvalue 202207L
464465
// # define __cpp_lib_ranges_chunk 202202L
465466
# define __cpp_lib_ranges_chunk_by 202202L
467+
# define __cpp_lib_ranges_contains 202207L
466468
// # define __cpp_lib_ranges_iota 202202L
467469
// # define __cpp_lib_ranges_join_with 202202L
468470
# define __cpp_lib_ranges_repeat 202207L
469471
// # define __cpp_lib_ranges_slide 202202L
470-
// # define __cpp_lib_ranges_starts_ends_with 202106L
472+
# define __cpp_lib_ranges_starts_ends_with 202106L
471473
# define __cpp_lib_ranges_to_container 202202L
472474
// # define __cpp_lib_ranges_zip 202110L
473475
// # define __cpp_lib_reference_from_temporary 202202L

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

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
__cpp_lib_freestanding_algorithm 202311L [C++26]
2222
__cpp_lib_parallel_algorithm 201603L [C++17]
2323
__cpp_lib_ranges 202207L [C++20]
24+
__cpp_lib_ranges_contains 202207L [C++23]
2425
__cpp_lib_ranges_starts_ends_with 202106L [C++23]
2526
__cpp_lib_robust_nonmodifying_seq_ops 201304L [C++14]
2627
__cpp_lib_sample 201603L [C++17]
@@ -52,6 +53,10 @@
5253
# error "__cpp_lib_ranges should not be defined before c++20"
5354
# endif
5455

56+
# ifdef __cpp_lib_ranges_contains
57+
# error "__cpp_lib_ranges_contains should not be defined before c++23"
58+
# endif
59+
5560
# ifdef __cpp_lib_ranges_starts_ends_with
5661
# error "__cpp_lib_ranges_starts_ends_with should not be defined before c++23"
5762
# endif
@@ -90,6 +95,10 @@
9095
# error "__cpp_lib_ranges should not be defined before c++20"
9196
# endif
9297

98+
# ifdef __cpp_lib_ranges_contains
99+
# error "__cpp_lib_ranges_contains should not be defined before c++23"
100+
# endif
101+
93102
# ifdef __cpp_lib_ranges_starts_ends_with
94103
# error "__cpp_lib_ranges_starts_ends_with should not be defined before c++23"
95104
# endif
@@ -143,6 +152,10 @@
143152
# error "__cpp_lib_ranges should not be defined before c++20"
144153
# endif
145154

155+
# ifdef __cpp_lib_ranges_contains
156+
# error "__cpp_lib_ranges_contains should not be defined before c++23"
157+
# endif
158+
146159
# ifdef __cpp_lib_ranges_starts_ends_with
147160
# error "__cpp_lib_ranges_starts_ends_with should not be defined before c++23"
148161
# endif
@@ -205,6 +218,10 @@
205218
# error "__cpp_lib_ranges should have the value 202207L in c++20"
206219
# endif
207220

221+
# ifdef __cpp_lib_ranges_contains
222+
# error "__cpp_lib_ranges_contains should not be defined before c++23"
223+
# endif
224+
208225
# ifdef __cpp_lib_ranges_starts_ends_with
209226
# error "__cpp_lib_ranges_starts_ends_with should not be defined before c++23"
210227
# endif
@@ -270,17 +287,18 @@
270287
# error "__cpp_lib_ranges should have the value 202207L in c++23"
271288
# endif
272289

273-
# if !defined(_LIBCPP_VERSION)
274-
# ifndef __cpp_lib_ranges_starts_ends_with
275-
# error "__cpp_lib_ranges_starts_ends_with should be defined in c++23"
276-
# endif
277-
# if __cpp_lib_ranges_starts_ends_with != 202106L
278-
# error "__cpp_lib_ranges_starts_ends_with should have the value 202106L in c++23"
279-
# endif
280-
# else // _LIBCPP_VERSION
281-
# ifdef __cpp_lib_ranges_starts_ends_with
282-
# error "__cpp_lib_ranges_starts_ends_with should not be defined because it is unimplemented in libc++!"
283-
# endif
290+
# ifndef __cpp_lib_ranges_contains
291+
# error "__cpp_lib_ranges_contains should be defined in c++23"
292+
# endif
293+
# if __cpp_lib_ranges_contains != 202207L
294+
# error "__cpp_lib_ranges_contains should have the value 202207L in c++23"
295+
# endif
296+
297+
# ifndef __cpp_lib_ranges_starts_ends_with
298+
# error "__cpp_lib_ranges_starts_ends_with should be defined in c++23"
299+
# endif
300+
# if __cpp_lib_ranges_starts_ends_with != 202106L
301+
# error "__cpp_lib_ranges_starts_ends_with should have the value 202106L in c++23"
284302
# endif
285303

286304
# ifndef __cpp_lib_robust_nonmodifying_seq_ops
@@ -353,17 +371,18 @@
353371
# error "__cpp_lib_ranges should have the value 202207L in c++26"
354372
# endif
355373

356-
# if !defined(_LIBCPP_VERSION)
357-
# ifndef __cpp_lib_ranges_starts_ends_with
358-
# error "__cpp_lib_ranges_starts_ends_with should be defined in c++26"
359-
# endif
360-
# if __cpp_lib_ranges_starts_ends_with != 202106L
361-
# error "__cpp_lib_ranges_starts_ends_with should have the value 202106L in c++26"
362-
# endif
363-
# else // _LIBCPP_VERSION
364-
# ifdef __cpp_lib_ranges_starts_ends_with
365-
# error "__cpp_lib_ranges_starts_ends_with should not be defined because it is unimplemented in libc++!"
366-
# endif
374+
# ifndef __cpp_lib_ranges_contains
375+
# error "__cpp_lib_ranges_contains should be defined in c++26"
376+
# endif
377+
# if __cpp_lib_ranges_contains != 202207L
378+
# error "__cpp_lib_ranges_contains should have the value 202207L in c++26"
379+
# endif
380+
381+
# ifndef __cpp_lib_ranges_starts_ends_with
382+
# error "__cpp_lib_ranges_starts_ends_with should be defined in c++26"
383+
# endif
384+
# if __cpp_lib_ranges_starts_ends_with != 202106L
385+
# error "__cpp_lib_ranges_starts_ends_with should have the value 202106L in c++26"
367386
# endif
368387

369388
# ifndef __cpp_lib_robust_nonmodifying_seq_ops

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

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
__cpp_lib_ranges_as_rvalue 202207L [C++23]
159159
__cpp_lib_ranges_chunk 202202L [C++23]
160160
__cpp_lib_ranges_chunk_by 202202L [C++23]
161+
__cpp_lib_ranges_contains 202207L [C++23]
161162
__cpp_lib_ranges_iota 202202L [C++23]
162163
__cpp_lib_ranges_join_with 202202L [C++23]
163164
__cpp_lib_ranges_repeat 202207L [C++23]
@@ -772,6 +773,10 @@
772773
# error "__cpp_lib_ranges_chunk_by should not be defined before c++23"
773774
# endif
774775

776+
# ifdef __cpp_lib_ranges_contains
777+
# error "__cpp_lib_ranges_contains should not be defined before c++23"
778+
# endif
779+
775780
# ifdef __cpp_lib_ranges_iota
776781
# error "__cpp_lib_ranges_iota should not be defined before c++23"
777782
# endif
@@ -1604,6 +1609,10 @@
16041609
# error "__cpp_lib_ranges_chunk_by should not be defined before c++23"
16051610
# endif
16061611

1612+
# ifdef __cpp_lib_ranges_contains
1613+
# error "__cpp_lib_ranges_contains should not be defined before c++23"
1614+
# endif
1615+
16071616
# ifdef __cpp_lib_ranges_iota
16081617
# error "__cpp_lib_ranges_iota should not be defined before c++23"
16091618
# endif
@@ -2607,6 +2616,10 @@
26072616
# error "__cpp_lib_ranges_chunk_by should not be defined before c++23"
26082617
# endif
26092618

2619+
# ifdef __cpp_lib_ranges_contains
2620+
# error "__cpp_lib_ranges_contains should not be defined before c++23"
2621+
# endif
2622+
26102623
# ifdef __cpp_lib_ranges_iota
26112624
# error "__cpp_lib_ranges_iota should not be defined before c++23"
26122625
# endif
@@ -3889,6 +3902,10 @@
38893902
# error "__cpp_lib_ranges_chunk_by should not be defined before c++23"
38903903
# endif
38913904

3905+
# ifdef __cpp_lib_ranges_contains
3906+
# error "__cpp_lib_ranges_contains should not be defined before c++23"
3907+
# endif
3908+
38923909
# ifdef __cpp_lib_ranges_iota
38933910
# error "__cpp_lib_ranges_iota should not be defined before c++23"
38943911
# endif
@@ -5357,6 +5374,13 @@
53575374
# error "__cpp_lib_ranges_chunk_by should have the value 202202L in c++23"
53585375
# endif
53595376

5377+
# ifndef __cpp_lib_ranges_contains
5378+
# error "__cpp_lib_ranges_contains should be defined in c++23"
5379+
# endif
5380+
# if __cpp_lib_ranges_contains != 202207L
5381+
# error "__cpp_lib_ranges_contains should have the value 202207L in c++23"
5382+
# endif
5383+
53605384
# if !defined(_LIBCPP_VERSION)
53615385
# ifndef __cpp_lib_ranges_iota
53625386
# error "__cpp_lib_ranges_iota should be defined in c++23"
@@ -5403,17 +5427,11 @@
54035427
# endif
54045428
# endif
54055429

5406-
# if !defined(_LIBCPP_VERSION)
5407-
# ifndef __cpp_lib_ranges_starts_ends_with
5408-
# error "__cpp_lib_ranges_starts_ends_with should be defined in c++23"
5409-
# endif
5410-
# if __cpp_lib_ranges_starts_ends_with != 202106L
5411-
# error "__cpp_lib_ranges_starts_ends_with should have the value 202106L in c++23"
5412-
# endif
5413-
# else // _LIBCPP_VERSION
5414-
# ifdef __cpp_lib_ranges_starts_ends_with
5415-
# error "__cpp_lib_ranges_starts_ends_with should not be defined because it is unimplemented in libc++!"
5416-
# endif
5430+
# ifndef __cpp_lib_ranges_starts_ends_with
5431+
# error "__cpp_lib_ranges_starts_ends_with should be defined in c++23"
5432+
# endif
5433+
# if __cpp_lib_ranges_starts_ends_with != 202106L
5434+
# error "__cpp_lib_ranges_starts_ends_with should have the value 202106L in c++23"
54175435
# endif
54185436

54195437
# ifndef __cpp_lib_ranges_to_container
@@ -7074,6 +7092,13 @@
70747092
# error "__cpp_lib_ranges_chunk_by should have the value 202202L in c++26"
70757093
# endif
70767094

7095+
# ifndef __cpp_lib_ranges_contains
7096+
# error "__cpp_lib_ranges_contains should be defined in c++26"
7097+
# endif
7098+
# if __cpp_lib_ranges_contains != 202207L
7099+
# error "__cpp_lib_ranges_contains should have the value 202207L in c++26"
7100+
# endif
7101+
70777102
# if !defined(_LIBCPP_VERSION)
70787103
# ifndef __cpp_lib_ranges_iota
70797104
# error "__cpp_lib_ranges_iota should be defined in c++26"
@@ -7120,17 +7145,11 @@
71207145
# endif
71217146
# endif
71227147

7123-
# if !defined(_LIBCPP_VERSION)
7124-
# ifndef __cpp_lib_ranges_starts_ends_with
7125-
# error "__cpp_lib_ranges_starts_ends_with should be defined in c++26"
7126-
# endif
7127-
# if __cpp_lib_ranges_starts_ends_with != 202106L
7128-
# error "__cpp_lib_ranges_starts_ends_with should have the value 202106L in c++26"
7129-
# endif
7130-
# else // _LIBCPP_VERSION
7131-
# ifdef __cpp_lib_ranges_starts_ends_with
7132-
# error "__cpp_lib_ranges_starts_ends_with should not be defined because it is unimplemented in libc++!"
7133-
# endif
7148+
# ifndef __cpp_lib_ranges_starts_ends_with
7149+
# error "__cpp_lib_ranges_starts_ends_with should be defined in c++26"
7150+
# endif
7151+
# if __cpp_lib_ranges_starts_ends_with != 202106L
7152+
# error "__cpp_lib_ranges_starts_ends_with should have the value 202106L in c++26"
71347153
# endif
71357154

71367155
# ifndef __cpp_lib_ranges_to_container

libcxx/utils/generate_feature_test_macro_components.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,11 @@ def add_version_header(tc):
914914
"values": {"c++23": 202202},
915915
"headers": ["ranges"],
916916
},
917+
{
918+
"name": "__cpp_lib_ranges_contains",
919+
"values": {"c++23": 202207},
920+
"headers": ["algorithm"],
921+
},
917922
{
918923
"name": "__cpp_lib_ranges_iota",
919924
"values": {"c++23": 202202},
@@ -941,7 +946,6 @@ def add_version_header(tc):
941946
"name": "__cpp_lib_ranges_starts_ends_with",
942947
"values": {"c++23": 202106},
943948
"headers": ["algorithm"],
944-
"unimplemented": True,
945949
},
946950
{
947951
"name": "__cpp_lib_ranges_to_container",

0 commit comments

Comments
 (0)