[libc++] Implement ranges::{all, any, none}_of
Reviewed By: ldionne, var-const, #libc
Spies: libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D123016
NOKEYCHECK=True
GitOrigin-RevId: 0e3dc1a52ffe8a2c7464d6acaeaec23eca21f4f4
diff --git a/include/algorithm b/include/algorithm
index aa21914..30f647c 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -305,6 +305,30 @@
constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {},
Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_iterator I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<input_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20
+
}
constexpr bool // constexpr in C++20
@@ -1021,6 +1045,8 @@
#include <__algorithm/pop_heap.h>
#include <__algorithm/prev_permutation.h>
#include <__algorithm/push_heap.h>
+#include <__algorithm/ranges_all_of.h>
+#include <__algorithm/ranges_any_of.h>
#include <__algorithm/ranges_copy.h>
#include <__algorithm/ranges_copy_backward.h>
#include <__algorithm/ranges_copy_if.h>
@@ -1043,6 +1069,7 @@
#include <__algorithm/ranges_minmax.h>
#include <__algorithm/ranges_minmax_element.h>
#include <__algorithm/ranges_mismatch.h>
+#include <__algorithm/ranges_none_of.h>
#include <__algorithm/ranges_reverse.h>
#include <__algorithm/ranges_swap_ranges.h>
#include <__algorithm/ranges_transform.h>