summaryrefslogtreecommitdiff
path: root/libcxx/include/__algorithm/set_intersection.h
AgeCommit message (Collapse)Author
2024-09-16[libc++][modules] Fix missing and incorrect includes (#108850)Louis Dionne
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-12[libc++][NFC] Use [[__nodiscard__]] unconditionally (#80454)Nikolas Klauser
`__has_cpp_attribute(__nodiscard__)` is always true now, so we might as well replace `_LIBCPP_NODISCARD`. It's one less macro that can result in bad diagnostics.
2024-07-18 [libc++] Speed up set_intersection() by fast-forwarding over ranges of ↵Iuri Chaer
non-matching elements with one-sided binary search. (#75230) One-sided binary search, aka meta binary search, has been in the public domain for decades, and has the general advantage of being constant time in the best case, with the downside of executing at most 2*log(N) comparisons vs classic binary search's exact log(N). There are two scenarios in which it really shines: the first one is when operating over non-random-access iterators, because the classic algorithm requires knowing the container's size upfront, which adds N iterator increments to the complexity. The second one is when traversing the container in order, trying to fast-forward to the next value: in that case the classic algorithm requires at least O(N*log(N)) comparisons and, for non-random-access iterators, O(N^2) iterator increments, whereas the one-sided version will yield O(N) operations on both counts, with a best-case of O(log(N)) comparisons which is very common in practice.
2024-01-25[libc++] Fix missing and incorrect push/pop macros (#79204)Louis Dionne
We recently noticed that the unwrap_iter.h file was pushing macros, but it was pushing them again instead of popping them at the end of the file. This led to libc++ basically swallowing any custom definition of these macros in user code: #define min HELLO #include <algorithm> // min is not HELLO anymore, it's not defined While investigating this issue, I noticed that our push/pop pragmas were actually entirely wrong too. Indeed, instead of pushing macros like `move`, we'd push `move(int, int)` in the pragma, which is not a valid macro name. As a result, we would not actually push macros like `move` -- instead we'd simply undefine them. This led to the following code not working: #define move HELLO #include <algorithm> // move is not HELLO anymore Fixing the pragma push/pop incantations led to a cascade of issues because we use identifiers like `move` in a large number of places, and all of these headers would now need to do the push/pop dance. This patch fixes all these issues. First, it adds a check that we don't swallow important names like min, max, move or refresh as explained above. This is done by augmenting the existing system_reserved_names.gen.py test to also check that the macros are what we expect after including each header. Second, it fixes the push/pop pragmas to work properly and adds missing pragmas to all the files I could detect a failure in via the newly added test. rdar://121365472
2023-06-06[libc++] Refactor __lessNikolas Klauser
This simplifies the usage of `__less` by making the class not depend on the types compared, but instead the `operator()`. We can't remove the template completely because we explicitly instantiate `std::__sort` with `__less<T>`. Reviewed By: ldionne, #libc Spies: arichardson, EricWF, libcxx-commits, mgrang Differential Revision: https://reviews.llvm.org/D145285
2022-10-01[libc++][NFC] Prefer type aliases over structsNikolas Klauser
Reviewed By: ldionne, #libc Spies: sstefan1, libcxx-commits, jeroen.dobbelaere Differential Revision: https://reviews.llvm.org/D134901
2022-08-19[libc++][NFC] Rename the constexpr macrosNikolas Klauser
This was discussed on Discord with the consensus that we should rename the macros. Reviewed By: ldionne, Mordante, var-const, avogelsgesang, jloser, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D131498
2022-07-13[libc++][ranges] implement `std::ranges::set_symmetric_difference`Hui Xie
[libc++][ranges] implement `std::ranges::set_symmetric_difference` Differential Revision: https://reviews.llvm.org/D129520
2022-07-13[libc++] Implement ranges::find_end, ranges::search{, _n}Nikolas Klauser
Reviewed By: var-const, #libc, huixie90 Spies: thakis, h-vetinari, huixie90, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D124079
2022-07-13Revert "[libc++] Implement ranges::find_end, ranges::search{, _n}"Nikolas Klauser
This reverts commit 76a76518507ccc59ccdad5b83f44dc8c3d9593c7.
2022-07-13[libc++] Implement ranges::find_end, ranges::search{, _n}Nikolas Klauser
Reviewed By: var-const, #libc, huixie90 Spies: h-vetinari, huixie90, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D124079
2022-07-12[lib++][ranges][NFC] Refactor `iterator_operations.h` to use tags.Konstantin Varlamov
Change the mechanism in `iterator_operations.h` to pass around a generic policy tag indicating whether an internal function is being invoked from a "classic" STL algorithm or a ranges algorithm. `IterOps` is now a template class specialized on the policy tag. The advantage is that this mechanism is more generic and allows defining arbitrary conditions in a clean manner. Also add a few more iterator functions to `IterOps`. Differential Revision: https://reviews.llvm.org/D129390
2022-07-11[libc++] Rename variables to use the snake case instead of camel caseHui Xie
For some reason the pre-commit CI of https://reviews.llvm.org/D129233 was all green so I didn't spot this https://reviews.llvm.org/B174525 Reviewed By: #libc, philnik, Mordante Differential Revision: https://reviews.llvm.org/D129503
2022-07-11[libc++][ranges] implement `std::ranges::set_intersection`Hui Xie
implement `std::ranges::set_intersection` by reusing the classic `std::set_intersenction` added unit tests Differential Revision: https://reviews.llvm.org/D129233
2022-03-01[libc++] Revert "Protect users from relying on detail headers" & related changesLouis Dionne
This commit reverts 5aaefa51 (and also partly 7f285f48e77 and b6d75682f9, which were related to the original commit). As landed, 5aaefa51 had unintended consequences on some downstream bots and didn't have proper coverage upstream due to a few subtle things. Implementing this is something we should do in libc++, however we'll first need to address a few issues listed in https://reviews.llvm.org/D106124#3349710. Differential Revision: https://reviews.llvm.org/D120683
2022-02-26[libcxx][modules] protects users from relying on detail headersChristopher Di Bella
libc++ has started splicing standard library headers into much more fine-grained content for maintainability. It's very likely that outdated and naive tooling (some of which is outside of LLVM's scope) will suggest users include things such as <__ranges/access.h> instead of <ranges>, and Hyrum's law suggests that users will eventually begin to rely on this without the help of tooling. As such, this commit intends to protect users from themselves, by making it a hard error for anyone outside of the standard library to include libc++ detail headers. Differential Revision: https://reviews.llvm.org/D106124
2022-02-04[libc++] Normalize all our '#pragma GCC system_header', and regression-test.Arthur O'Dwyer
Now we'll notice if a header forgets to include this magic phrase. Differential Revision: https://reviews.llvm.org/D118800
2022-01-10[libc++] Alphabetize header #includes. NFCI.Arthur O'Dwyer
The NFC part of D116809. We still want to enforce this in CI, but the mechanism for that is still to-be-determined. Differential Revision: https://reviews.llvm.org/D116809
2021-08-27[libc++][NFC] Remove useless _LIBCPP_PUSH_MACROSLouis Dionne
Only files that actually use min/max are required to do this dance. Differential Revision: https://reviews.llvm.org/D108778
2021-06-19[libcxx] Move all algorithms into their own headersLouis Dionne
This is a fairly mechanical change, it just moves each algorithm into its own header. This is intended to be a NFC. This commit re-applies 7ed7d4ccb899, which was reverted in 692d7166f771 because the Modules build got broken. The modules build has now been fixed, so we're re-committing this. Differential Revision: https://reviews.llvm.org/D103583 Attribution note ---------------- I'm only committing this. This commit is a mix of D103583, D103330 and D104171 authored by: Co-authored-by: Christopher Di Bella <cjdb@google.com> Co-authored-by: zoecarver <z.zoelec2@gmail.com>
2021-06-07Revert "[libcxx][gardening] Move all algorithms into their own headers."Petr Hosek
This reverts commit 7ed7d4ccb8991e2b5b95334b508f8cec2faee737 as it uncovered a Clang bug PR50592.
2021-06-04[libcxx][gardening] Move all algorithms into their own headers.zoecarver
This is a fairly mechanical change, it just moves each algorithm into its own header. This is a NFC. Note: during this change, I burned down all the includes, so this follows "include only and exactly what you use." Differential Revision: https://reviews.llvm.org/D103583