Louis Dionne
09e3a36058
[libc++][modules] Fix missing and incorrect includes ( #108850 )
...
This patch adds a large number of missing includes in the libc++ headers
and the test suite. Those were found as part of the effort to move
towards a mostly monolithic top-level std module.
2024-09-16 15:06:20 -04:00
nicole mazzuca
04760bfadb
[libc++][ranges] P1223R5: find_last
( #99312 )
...
Implements [P1223R5][] completely.
Includes an implementation of `find_last`, `find_last_if`, and
`find_last_if_not`.
[P1223R5]: https://wg21.link/p1223r5
2024-07-19 09:42:16 -07:00
ZijunZhaoCCK
a6b846ae1e
[libc++][ranges] Implement ranges::contains_subrange ( #66963 )
2024-02-13 15:42:37 -08:00
Christopher Di Bella
3903438860
[libcxx] adds ranges::fold_left_with_iter and ranges::fold_left ( #75259 )
...
Notable things in this commit:
* refactors `__indirect_binary_left_foldable`, making it slightly
different (but equivalent) to _`indirect-binary-left-foldable`_, which
improves readability (a [patch to the Working Paper][patch] was made)
* omits `__cpo` namespace, since it is not required for implementing
niebloids (a cleanup should happen in 2024)
* puts tests ensuring invocable robustness and dangling correctness
inside the correctness testing to ensure that the algorithms' results
are still correct
[patch]: https://github.com/cplusplus/draft/pull/6734
2023-12-19 21:57:50 -08:00
ZijunZhaoCCK
fdd089b500
[libc++] Implement ranges::contains ( #65148 )
...
Differential Revision: https://reviews.llvm.org/D159232
```
Running ./ranges_contains.libcxx.out
Run on (10 X 24.121 MHz CPU s)
CPU Caches:
L1 Data 64 KiB (x10)
L1 Instruction 128 KiB (x10)
L2 Unified 4096 KiB (x5)
Load Average: 3.37, 6.77, 5.27
--------------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------------
bm_contains_char/16 1.88 ns 1.87 ns 371607095
bm_contains_char/256 7.48 ns 7.47 ns 93292285
bm_contains_char/4096 99.7 ns 99.6 ns 7013185
bm_contains_char/65536 1296 ns 1294 ns 540436
bm_contains_char/1048576 23887 ns 23860 ns 29302
bm_contains_char/16777216 389420 ns 389095 ns 1796
bm_contains_int/16 7.14 ns 7.14 ns 97776288
bm_contains_int/256 90.4 ns 90.3 ns 7558089
bm_contains_int/4096 1294 ns 1290 ns 543052
bm_contains_int/65536 20482 ns 20443 ns 34334
bm_contains_int/1048576 328817 ns 327965 ns 2147
bm_contains_int/16777216 5246279 ns 5239361 ns 133
bm_contains_bool/16 2.19 ns 2.19 ns 322565780
bm_contains_bool/256 3.42 ns 3.41 ns 205025467
bm_contains_bool/4096 22.1 ns 22.1 ns 31780479
bm_contains_bool/65536 333 ns 332 ns 2106606
bm_contains_bool/1048576 5126 ns 5119 ns 135901
bm_contains_bool/16777216 81656 ns 81574 ns 8569
```
---------
Co-authored-by: Nathan Gauër <brioche@google.com>
2023-12-19 16:34:19 -08:00
Jakub Mazurkiewicz
6a66467499
[libc++] P2770R0: Stashing stashing iterators for proper flattening ( #66033 )
...
- Partially implements P2770R0 (http://wg21.link/p2770 )
- Fixes https://wg21.link/LWG3698 , https://wg21.link/LWG3700 , and https://wg21.link/LWG3791
- join_with_view hasn't been done yet since this type isn't implemented yet
- Rename tuple test directory to match the standard (which changed in P2770R0)
- Rename join_view test directory to match the standard
2023-12-12 09:45:14 -05:00
Zijun Zhao
0218ea4aaa
[libc++] Implement ranges::ends_with
...
Reviewed By: #libc, var-const
Differential Revision: https://reviews.llvm.org/D150831
2023-09-18 11:56:10 -07:00
zijunzhao
205175578e
[libc++] Implement ranges::starts_with
2023-05-15 18:15:38 +00:00
varconst
c2b3986e39
[libc++][ranges] Temporarily mark ranges::join_view
as experimental.
...
This is in anticipation of https://isocpp.org/files/papers/D2770R0.html ,
which is ABI-breaking for `join_view`.
Differential Revision: https://reviews.llvm.org/D142520
2023-01-30 00:36:07 -08:00
Nikolas Klauser
430b397f67
[libc++] Granularize <type_traits> includes in <iterator>
...
Reviewed By: Mordante, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D140621
2022-12-27 02:32:16 +01:00
Louis Dionne
b8cb1dc9ea
[libc++] Make <ranges> non-experimental
...
When we ship LLVM 16, <ranges> won't be considered experimental anymore.
We might as well do this sooner rather than later.
Differential Revision: https://reviews.llvm.org/D132151
2022-08-18 16:59:58 -04:00
Konstantin Varlamov
8ac015caf6
[libc++][ranges][NFC] Make sure all implemented algorithms are enabled in "robust" tests.
...
Also fix `std::find_first_of` (which accidentally copied the predicate
in the implementation).
Differential Revision: https://reviews.llvm.org/D131235
2022-08-05 14:02:12 -07:00
Nikolas Klauser
4038c859e5
[libc++][ranges] Implement ranges::is_permutation
...
Co-authored-by: Konstantin Varlamov <varconst@apple.com>
Differential Revision: https://reviews.llvm.org/D127194
2022-08-04 10:54:37 -07:00
Nikolas Klauser
a203acb9dd
[libc++][ranges] Implement ranges::clamp
...
Differential Revision: https://reviews.llvm.org/D126193
2022-08-04 02:45:32 -07:00
Konstantin Varlamov
36c746ca2d
[libc++][ranges] Implement ranges::rotate
.
...
Also fix `ranges::stable_sort` and `ranges::inplace_merge` to support
proxy iterators now that their internal implementations can correctly
dispatch `rotate`.
Differential Revision: https://reviews.llvm.org/D130758
2022-08-03 16:04:24 -07:00
Konstantin Varlamov
6bdb642234
[libc++][ranges] Implement ranges::sample
.
...
Differential Revision: https://reviews.llvm.org/D130865
2022-08-02 22:34:23 -07:00
Nikolas Klauser
93172c1c2b
[libc++][ranges] Implement ranges::replace_copy{,_if}
.
...
Co-authored-by: Konstantin Varlamov <varconst@apple.com>
Differential Revision: https://reviews.llvm.org/D129806
2022-08-02 22:32:01 -07:00
Nikolas Klauser
760d2b462c
[libc++][ranges] Implement ranges::remove_copy{, _if}
.
...
Co-authored-by: Hui Xie <hui.xie1990@gmail.com>
Differential Revision: https://reviews.llvm.org/D130599
2022-08-02 22:19:13 -07:00
Konstantin Varlamov
db7d795978
[libc++][ranges] Implement std::ranges::partial_sort_copy
.
...
Differential Revision: https://reviews.llvm.org/D130532
2022-07-30 02:42:18 -07:00
Hui Xie
72f57e3a30
[libc++][ranges] implement std::ranges::unique{_copy}
...
implement `std::ranges::unique` and `std::ranges::unique_copy`
Differential Revision: https://reviews.llvm.org/D130404
2022-07-29 08:28:17 +01:00
Hui Xie
8a61749f76
[libc++][ranges] implement std::ranges::inplace_merge
...
Differential Revision: https://reviews.llvm.org/D130627
2022-07-28 08:37:48 +01:00
Konstantin Varlamov
d406c6493e
[libc++][ranges] Implement ranges::is_heap{,_until}
.
...
Differential Revision: https://reviews.llvm.org/D130547
2022-07-26 16:11:24 -07:00
Konstantin Varlamov
ead7302bbb
[libc++][ranges] Implement ranges::generate{,_n}
.
...
Differential Revision: https://reviews.llvm.org/D130552
2022-07-26 15:50:32 -07:00
Konstantin Varlamov
14cf74d65d
[libc++][ranges] Implement ranges::shuffle
.
...
Differential Revision: https://reviews.llvm.org/D130321
2022-07-22 09:59:13 -07:00
Hui Xie
c559964d85
[libc++][ranges] implement std::ranges::includes
...
implement `std::ranges::includes` and delegate to `std::includes`
Differential Revision: https://reviews.llvm.org/D130116
2022-07-22 10:27:48 +01:00
Hui Xie
0f6364b8a1
[libc++][ranges] implement std::ranges::equal_range
...
implement `std::ranges::equal_range` which delegates to
`std::equal_range`
Differential Revision: https://reviews.llvm.org/D129796
2022-07-22 10:24:08 +01:00
Konstantin Varlamov
065202f3ca
[libc++][ranges] Implement std::ranges::partition_{point,copy}
.
...
Reviewed By: #libc, huixie90, ldionne
Differential Revision: https://reviews.llvm.org/D130070
2022-07-20 11:39:07 -07:00
varconst
5dd19ada57
[libc++][ranges] Implement ranges::partial_sort
.
...
Differential Revision: https://reviews.llvm.org/D128744
2022-07-19 20:10:34 -07:00
Konstantin Varlamov
8ed702b83f
[libc++][ranges] Implement ranges::{,stable_}partition
.
...
Differential Revision: https://reviews.llvm.org/D129624
2022-07-18 21:06:17 -07:00
Hui Xie
3151b95dad
[libc++][ranges] implement std::ranges::set_union
...
[libc++][ranges] implement `std::ranges::set_union`
Differential Revision: https://reviews.llvm.org/D129657
2022-07-14 21:05:30 +01:00
Hui Xie
a5c0638dec
[libc++][ranges] implement std::ranges::set_symmetric_difference
...
[libc++][ranges] implement `std::ranges::set_symmetric_difference`
Differential Revision: https://reviews.llvm.org/D129520
2022-07-13 21:24:32 +01:00
Nikolas Klauser
101d1e9b3c
[libc++] Implement ranges::find_end, ranges::search{, _n}
...
Reviewed By: var-const, #libc, huixie90
Spies: thakis, h-vetinari, huixie90, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D124079
2022-07-13 20:30:55 +02:00
Nikolas Klauser
1f04759316
Revert "[libc++] Implement ranges::find_end, ranges::search{, _n}"
...
This reverts commit 76a76518507ccc59ccdad5b83f44dc8c3d9593c7.
2022-07-13 13:41:25 +02:00
Nikolas Klauser
76a7651850
[libc++] Implement ranges::find_end, ranges::search{, _n}
...
Reviewed By: var-const, #libc, huixie90
Spies: h-vetinari, huixie90, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D124079
2022-07-13 13:11:26 +02:00
Konstantin Varlamov
73ebcabff2
[libc++][ranges][NFC] Implement the repetitive parts of the remaining range algorithms:
...
- create the headers (but not include them from `<algorithm>`);
- define the niebloid and its member functions with the right signatures
(as no-ops);
- make sure all the right headers are included that are required by each
algorithm's signature;
- update `CMakeLists.txt` and the module map;
- create the test files with the appropriate synopses.
The synopsis in `<algorithm>` is deliberately not updated because that
could be taken as a readiness signal. The new headers aren't included
from `<algorithm>` for the same reason.
Differential Revision: https://reviews.llvm.org/D129549
2022-07-12 02:48:31 -07:00
Nikolas Klauser
7d426a392f
[libc++] Implement ranges::{reverse, rotate}_copy
...
Reviewed By: var-const, #libc
Spies: huixie90, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D127211
2022-07-11 21:13:08 +02:00
Hui Xie
96b674f23c
[libc++][ranges] implement std::ranges::set_intersection
...
implement `std::ranges::set_intersection` by reusing the classic `std::set_intersenction`
added unit tests
Differential Revision: https://reviews.llvm.org/D129233
2022-07-11 06:55:09 +01:00
Konstantin Varlamov
c945bd0da6
[libc++][ranges] Implement modifying heap algorithms:
...
- `ranges::make_heap`;
- `ranges::push_heap`;
- `ranges::pop_heap`;
- `ranges::sort_heap`.
Differential Revision: https://reviews.llvm.org/D128115
2022-07-08 13:48:41 -07:00
Konstantin Varlamov
23c7328bad
[libc++][ranges] Implement ranges::nth_element
.
...
Differential Revision: https://reviews.llvm.org/D128149
2022-07-08 11:26:02 -07:00
Hui Xie
1cdec6c96e
[libcxx][ranges] implement std::ranges::set_difference
...
implement `std::ranges::set_difference`
reused classic std::set_difference
added unit tests
Differential Revision: https://reviews.llvm.org/D128983
2022-07-08 13:26:23 +01:00
Nikolas Klauser
f8cbe3cdf0
[libc++] Implement ranges::remove{, _if}
...
Reviewed By: var-const, #libc
Spies: huixie90, sstefan1, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D128618
2022-07-06 18:47:13 +02:00
Hui Xie
25607d143d
[libc++] Implement std::ranges::merge
...
Implement `std::ranges::merge`. added unit tests
Differential Revision: https://reviews.llvm.org/D128611
2022-07-04 13:44:31 +01:00
Konstantin Varlamov
94c7b89fe5
[libc++][ranges] Implement ranges::stable_sort
.
...
Differential Revision: https://reviews.llvm.org/D127834
2022-07-01 16:34:26 -07:00
Nikolas Klauser
2c3bbac0c7
[libc++] Implement ranges::move{, _backward}
...
This patch also adds a new optimization to `std::move`. It unwraps three `reverse_iterator`s if the wrapped iterator is a `contiguous_iterator` and the iterated type is trivially_movable. This allows us to simplify `ranges::move_backward` to a forward to `std::move` without any pessimization.
Reviewed By: var-const, #libc
Spies: libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D126616
2022-06-23 13:52:49 +02:00
Konstantin Varlamov
ff3989e6ae
[libc++][ranges] Implement ranges::sort
.
...
Differential Revision: https://reviews.llvm.org/D127557
2022-06-16 15:21:06 -07:00
Nikolas Klauser
afd5a4f2dc
[libc++] Implement ranges::lexicographical_compare
...
Reviewed By: var-const, Mordante, #libc
Spies: H-G-Hristov, sstefan1, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D127130
2022-06-15 22:29:21 +02:00
Nikolas Klauser
ff6d5dee71
[libc++] Implement ranges::replace{, _if}
...
Reviewed By: var-const, #libc
Spies: libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D126283
2022-06-10 11:54:46 +02:00
Nikolas Klauser
916e9052ba
[libc++] Implement ranges::adjacent_find
...
Reviewed By: Mordante, var-const, #libc
Spies: libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D126610
2022-06-08 12:15:03 +02:00
Nikolas Klauser
8171586176
[libc++][ranges] Implement ranges::binary_search and ranges::{lower, upper}_bound
...
Reviewed By: Mordante, var-const, ldionne, #libc
Spies: sstefan1, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D121964
2022-06-06 13:33:18 +02:00
Nikolas Klauser
3606da5fba
[libc++] Enable ranges_robust_against* and niebloid tests for implemented ranges algorithms
...
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D126477
2022-05-27 10:40:01 +02:00