summaryrefslogtreecommitdiff
path: root/libcxx/include/functional
AgeCommit message (Collapse)Author
2025-07-06[libc++] P2655R3 common_reference_t of reference_wrapper Should Be a ↵Hui
Reference Type (#141408) Fixes #105260 This patch applies the change as a DR to C++20. The rationale is that the paper is more like a bug fix. It does not introduce new features, it simply changes an existing behaviour (as a bug fix). MSVC STL DRed this paper to C++20 as well.
2025-07-02[libc++] Avoid including vector in <functional> (#144310)Nikolas Klauser
`vector` has been used in a very simple way in `boyer_moore_searcher`. We can instead just use `unique_ptr<T[]>`, which is a lot simpler, allowing us to drop the `vector` dependency while not losing any expressiveness in the code. As a nice side effect, this also reduces the time it takes to instantiate the `boyer_moore_searcher` constructor from 26ms to 22ms on my machine.
2025-01-10[libc++] Implement std::not_fn<NTTP> (#86133)Jakub Mazurkiewicz
Implement `std::not_fn<NTTP>` from "P2714R1 Bind front and back to NTTP callables".
2024-12-21[libc++][C++03] Use `__cxx03/` headers in C++03 mode (#109002)Nikolas Klauser
This patch implements the forwarding to frozen C++03 headers as discussed in https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc. In the RFC, we initially proposed selecting the right headers from the Clang driver, however consensus seemed to steer towards handling this in the library itself. This patch implements that direction. At a high level, the changes basically amount to making each public header look like this: ``` // inside <vector> #ifdef _LIBCPP_CXX03_LANG # include <__cxx03/vector> #else // normal <vector> content #endif ``` In most cases, public headers are simple umbrella headers so there isn't much code in the #else branch. In other cases, the #else branch contains the actual implementation of the header.
2024-12-10[libc++] Add #if 0 block to all the top-level headers (#119234)Nikolas Klauser
Including The frozen C++03 headers results in a lot of formatting changes in the main headers, so this splits these changes into a separate commit instead. This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc.
2024-10-25[libc++] Granularize <vector> (#99705)Nikolas Klauser
| | old time | new time | | ------------------ | -------- | -------- | | functional - c++23 | 416ms | 225ms | | random - c++23 | 513ms | 392ms | | vector - c++17 | 206ms | 100ms |
2024-10-15[libc++] Fix expression-equivalence for `mem_fn` (#111307)A. Jiang
Previously, SFINAE constraints and exception specification propagation were missing in the return type of libc++'s `std::mem_fn`. The requirements on expression-equivalence (or even plain "equivalent" in pre-C++20 specification) in [func.memfn] are actually requiring them. This PR adds the missed stuffs. Fixes #86043. Drive-by changes: - removing no longer used `__invoke_return`, - updating synopsis comments in several files, and - merging several test files for `mem_fn` into one.
2024-07-18[libc++] Include the rest of the detail headers by version in the umbrella ↵Nikolas Klauser
headers (#96032) This is a follow-up to #83740.
2024-05-09[libc++][functional] P2944R3 (partial): Comparisons for `reference_wrapper` ↵Hristo Hristov
(`reference_wrapper` operators only) (#88384) Implements https://wg21.link/P2944R3 (partially) Implements https://wg21.link/LWG4071 / https://cplusplus.github.io/LWG/issue4071 (fixes build failures in the test suite) - https://eel.is/c++draft/refwrap.comparisons
2024-04-09[libc++] Implement `bind_back` (#81055)Jakub Mazurkiewicz
Implement `std::bind_back` function from P2387R3 "Pipe support for user-defined range adaptors".
2024-02-29[libc++] Clean up includes of <__assert> (#80091)Louis Dionne
Originally, we used __libcpp_verbose_abort to handle assertion failures. That function was declared from all public headers. Since we don't use that mechanism anymore, we don't need to declare __libcpp_verbose_abort from all public headers, and we can clean up a lot of unnecessary includes. This patch also moves the definition of the various assertion categories to the <__assert> header, since we now rely on regular IWYU for these assertion macros. rdar://105510916
2023-10-29[libc++] Remove a few transitive includes (#70553)philnik777
2023-10-10[libc++][NFC] Fix typo in synopsis commentLouis Dionne
2023-06-29[libc++] Remove the legacy debug mode.varconst
See https://discourse.llvm.org/t/rfc-removing-the-legacy-debug-mode-from-libc/71026 Reviewed By: #libc, Mordante, ldionne Differential Revision: https://reviews.llvm.org/D153672
2023-06-12[libc++][spaceship] P1614R2: Removed `operator!=` from `functional`Hristo Hristov
Implements parts of P1614R2: - Removed `operator!=` from `functional` Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D152704
2023-05-14[libc++] Moves unwrap_reference to type_traits.Mark de Wever
This was discovered while working on modules. Reviewed By: #libc, philnik Differential Revision: https://reviews.llvm.org/D149351
2023-04-09[libc++] Remove <cstdlib> includesNikolas Klauser
We changed the `abort` calls when trying to throw exceptions in `-fno-exceptions` mode to `__verbose_abort` calls, which removes the dependency in most files. Reviewed By: ldionne, #libc Spies: dim, emaste, mikhail.ramalho, smeenai, libcxx-commits Differential Revision: https://reviews.llvm.org/D146076
2023-03-19[libc++] Granularize <exception> includesNikolas Klauser
Reviewed By: ldionne, #libc Spies: mikhail.ramalho, smeenai, libcxx-commits Differential Revision: https://reviews.llvm.org/D146097
2023-03-10[libc++] Granularize <atomic> includesNikolas Klauser
Reviewed By: ldionne, Mordante, #libc Spies: arichardson, libcxx-commits Differential Revision: https://reviews.llvm.org/D144255
2023-03-08[libc++] Granularize <type_traits> includesNikolas Klauser
Reviewed By: ldionne, #libc, #libc_abi Spies: #libc_vendors, smeenai, libcxx-commits Differential Revision: https://reviews.llvm.org/D145320
2023-02-27[libc++] Improves clang-format settings.Mark de Wever
Add a new test based .clang-format file which inherits from the generic one. This moves some test specific formatting rules to the test directory. The main benefit is that headers are sorted, which makes it more likely to catch these errors before creating a review instead of spotting the error in the CI clang-tidy step. Reviewed By: ldionne, philnik, #libc Differential Revision: https://reviews.llvm.org/D144755
2023-02-17[libc++][NFC] Remove TODOs that are already doneNikolas Klauser
2023-02-13[libc++] Implement P2136R3 std::invoke_rLouis Dionne
Differential Revision: https://reviews.llvm.org/D143610
2023-01-31[libc++] Addresses LWG3764.Mark de Wever
LWG3764 reference_wrapper::operator() should propagate noexcept As drive-by adds constexpr to the synopsis, since it has already been implemented. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D142814
2022-11-05[libc++] Granularize <concept> includesNikolas Klauser
Reviewed By: ldionne, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D137283
2022-09-18[libc++] Avoid including <tuple> in compressed_pair.hNikolas Klauser
compressed_pair is widely used in the library, but most of the uses don't use the tuple parts. To avoid including <tuple> everywhere, use the forward declaration instead in compressed_pair.h Reviewed By: ldionne, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D133331
2022-09-05[libc++] Granularize the rest of memoryNikolas Klauser
Reviewed By: ldionne, #libc Spies: vitalybuka, paulkirth, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D132790
2022-09-03[NFC][libc++] Moves transitive includes location.Mark de Wever
As discussed in D132284 they will be moved to the end. Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D133212
2022-09-02Revert "[libc++] Granularize the rest of memory"Vitaly Buka
Breaks buildbots. This reverts commit 30adaa730c4768b5eb06719c808b2884fcf53cf3.
2022-09-02[libc++] Granularize the rest of memoryNikolas Klauser
Reviewed By: ldionne, #libc Spies: libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D132790
2022-08-31[libc++] Reduces the number of transitive includes.Mark de Wever
This defines a new policy for removal of transitive includes. The goal of the policy it to make it relatively easy to remove headers when needed, but avoid breaking developers using and vendors shipping libc++. The method used is to guard transitive includes based on the C++ language version. For the upcoming C++23 we can remove headers when we want, but for other language versions we try to keep it to a minimum. In this code the transitive include of `<chrono>` is removed since D128577 introduces a header cycle between `<format>` and `<chrono>`. This cycle is indirectly required by the Standard. Our cycle dependency tool basically is a grep based tool, so it needs some hints to ignore cycles. With the input of our transitive include tests we can create a better tool. However that's out of the scope of this patch. Note the flag `_LIBCPP_REMOVE_TRANSITIVE_INCLUDES` remains unchanged. So users can still opt-out of transitives includes entirely. Reviewed By: #libc, ldionne, philnik Differential Revision: https://reviews.llvm.org/D132284
2022-06-28[libc++][ranges] Finish LWG issues directly related to the One Ranges Proposal.Konstantin Varlamov
- P1252 ("Ranges Design Cleanup") -- deprecate `move_iterator::operator->` starting from C++20; add range comparisons to the `<functional>` synopsis. This restores `move_iterator::operator->` that was incorrectly deleted in D117656; it's still defined in the latest draft, see http://eel.is/c++draft/depr.move.iter.elem. Note that changes to `*_result` types from 6.1 in the paper are no longer relevant now that these types are aliases; - P2106 ("Alternative wording for GB315 and GB316") -- add a few `*_result` types to the synopsis in `<algorithm>` (some algorithms are not implemented yet and thus some of the proposal still cannot be marked as done); Also mark already done issues as done (or as nothing to do): - P2091 ("Fixing Issues With Range Access CPOs") was already implemented (this patch adds tests for some ill-formed cases); - LWG 3247 ("`ranges::iter_move` should perform ADL-only lookup of `iter_move`") was already implemented; - LWG 3300 ("Non-array ssize overload is underconstrained") doesn't affect the implementation; - LWG 3335 ("Resolve C++20 NB comments US 273 and GB 274") was already implemented; - LWG 3355 ("The memory algorithms should support move-only input iterators introduced by P1207") was already implemented (except for testing). Differential Revision: https://reviews.llvm.org/D126053
2022-06-27[libc++] Re-add transitive includes that had been removed since LLVM 14Louis Dionne
This commit re-adds transitive includes that had been removed by 4cd04d1687f1, c36870c8e79c, a83f4b9cda57, 1458458b558d, 2e2f3158c604, and 489637e66dd3. This should cover almost all the includes that had been removed since LLVM 14 and that would contribute to breaking user code when releasing LLVM 15. It is possible to disable the inclusion of these headers by defining _LIBCPP_REMOVE_TRANSITIVE_INCLUDES. The intent is that vendors will enable that macro and start fixing downstream issues immediately. We can then remove the macro (and the transitive includes) by default in a future release. That way, we will break users only once by removing transitive includes in bulk instead of doing it bit by bit a every release, which is more disruptive for users. Note 1: The set of headers to re-add was found by re-generating the transitive include test on a checkout of release/14.x, which provided the list of all transitive includes we used to provide. Note 2: Several includes of <vector>, <optional>, <array> and <unordered_map> have been added in this commit. These transitive inclusions were added when we implemented boyer_moore_searcher in <functional>. Note 3: This is a best effort patch to try and resolve downstream breakage caused since branching LLVM 14. I wasn't able to perfectly mirror transitive includes in LLVM 14 for a few headers, so I added a release note explaining it. To summarize, adding boyer_moore_searcher created a bunch of circular dependencies, so we have to break backwards compatibility in a few cases. Differential Revision: https://reviews.llvm.org/D128661
2022-06-17[libc++] Implement std::boyer_moore{, _horspool}_searcherNikolas Klauser
This mostly copys the `<experimental/functional>` stuff and updates the code to current libc++ style. Reviewed By: ldionne, #libc Spies: nlopes, adamdebreceni, arichardson, libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D121074
2022-03-30[libc++] Ensure that all public C++ headers include <__assert>Louis Dionne
This patch changes the requirement for getting the declaration of the assertion handler from including <__assert> to including any public C++ header of the library. Note that C compatibility headers are excluded because we don't implement all the C headers ourselves -- some of them are taken straight from the C library, like assert.h. It also adds a generated test to check it. Furthermore, this new generated test is designed in a way that will make it possible to replace almost all the existing test-generation scripts with this system in upcoming patches. Differential Revision: https://reviews.llvm.org/D122506
2022-03-17[libc++] Remove <utility> includesNikolas Klauser
Reviewed By: ldionne, Quuxplusone, #libc Spies: libcxx-commits, arphaman Differential Revision: https://reviews.llvm.org/D121054
2022-03-05[libc++] Granularize <utility> includesNikolas Klauser
Reviewed By: ldionne, #libc Spies: EricWF, libcxx-commits, arphaman Differential Revision: https://reviews.llvm.org/D120466
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-10-10[libc++] [P1614] Implement std::compare_three_way.Arthur O'Dwyer
Differential Revision: https://reviews.llvm.org/D110735
2021-08-11[libc++] Add the __bind_back and __compose helpersLouis Dionne
Those are going to be used to implement range adaptors, see D107098 for details. Differential Revision: https://reviews.llvm.org/D107785
2021-07-01[libcxx][functional][modular] splices <functional> into modular headersChristopher Di Bella
Differential Revision: https://reviews.llvm.org/D104942
2021-06-29[libc++] NFCI: Remove __functional/search.hLouis Dionne
The __search helper function was once split into __functional for circular dependency reasons, however this is not an issue anymore now that we have finer grained headers.
2021-06-25[libcxx][modularisation] splits `<utility>` into self-contained headersChristopher Di Bella
* moves `std::hash` and `std::unary_function` into `__functional` * Everything else goes into `__utility/${NAME}.h` Differential Revision: https://reviews.llvm.org/D104002
2021-06-24[libcxx][modularisation] moves <utility> content out of <type_traits>Christopher Di Bella
Moves: * `std::move`, `std::forward`, `std::declval`, and `std::swap` into `__utility/${FUNCTION_NAME}`. * `std::swap_ranges` and `std::iter_swap` into `__algorithm/${FUNCTION_NAME}` Differential Revision: https://reviews.llvm.org/D103734
2021-06-22[libc++] Enable `explicit` conversion operators, even in C++03 mode.Arthur O'Dwyer
C++03 didn't support `explicit` conversion operators; but Clang's C++03 mode does, as an extension, so we can use it. This lets us make the conversion explicit in `std::function` (even in '03), and remove some silly metaprogramming in `std::basic_ios`. Drive-by improvements to the tests for these operators, in addition to making sure all these tests also run in `c++03` mode. Differential Revision: https://reviews.llvm.org/D104682
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-15[libc++] [P0619] Add _LIBCPP_ABI_NO_BINDER_BASES and remove binder typedefs ↵Arthur O'Dwyer
in C++20. Differential Revision: https://reviews.llvm.org/D103753
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