From 04760bfadb399cc4ded9b32bd523ec7703aa7462 Mon Sep 17 00:00:00 2001 From: nicole mazzuca Date: Fri, 19 Jul 2024 09:42:16 -0700 Subject: [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 --- libcxx/include/algorithm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'libcxx/include/algorithm') diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index a522a60f1b55..698e6f5cb7ad 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -102,6 +102,31 @@ namespace ranges { constexpr borrowed_iterator_t find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20 + template S, class T, class Proj = identity> + requires indirect_binary_predicate, const T*> + constexpr subrange find_last(I first, S last, const T& value, Proj proj = {}); // since C++23 + + template + requires + indirect_binary_predicate, Proj>, const T*> + constexpr borrowed_subrange_t find_last(R&& r, const T& value, Proj proj = {}); // since C++23 + + template S, class Proj = identity, + indirect_unary_predicate> Pred> + constexpr subrange find_last_if(I first, S last, Pred pred, Proj proj = {}); // since C++23 + + template, Proj>> Pred> + constexpr borrowed_subrange_t find_last_if(R&& r, Pred pred, Proj proj = {}); // since C++23 + + template S, class Proj = identity, + indirect_unary_predicate> Pred> + constexpr subrange find_last_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++23 + + template, Proj>> Pred> + constexpr borrowed_subrange_t find_last_if_not(R&& r, Pred pred, Proj proj = {}); // since C++23 + template> Comp = ranges::less> constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 @@ -1989,6 +2014,7 @@ template # include <__algorithm/fold.h> # include <__algorithm/ranges_contains_subrange.h> # include <__algorithm/ranges_ends_with.h> +# include <__algorithm/ranges_find_last.h> # include <__algorithm/ranges_starts_with.h> #endif // _LIBCPP_STD_VER >= 23 -- cgit v1.2.3