[libc++] Implement ranges::remove{, _if}
Reviewed By: var-const, #libc
Spies: huixie90, sstefan1, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D128618
NOKEYCHECK=True
GitOrigin-RevId: f8cbe3cdf024865eaa26c14fc8e8f43b3cad455a
diff --git a/include/algorithm b/include/algorithm
index 76bdf3b..a7236a3 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -511,6 +511,26 @@
merge(R1&& r1, R2&& r2, O result,
Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20
+ template<permutable I, sentinel_for<I> S, class T, class Proj = identity>
+ requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
+ constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {}); // since C++20
+
+ template<forward_range R, class T, class Proj = identity>
+ requires permutable<iterator_t<R>> &&
+ indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
+ constexpr borrowed_subrange_t<R>
+ ranges::remove(R&& r, const T& value, Proj proj = {}); // since C++20
+
+ template<permutable I, sentinel_for<I> S, class Proj = identity,
+ indirect_unary_predicate<projected<I, Proj>> Pred>
+ constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {}); // since C++20
+
+ template<forward_range R, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires permutable<iterator_t<R>>
+ constexpr borrowed_subrange_t<R>
+ ranges::remove_if(R&& r, Pred pred, Proj proj = {}); // since C++20
+
}
constexpr bool // constexpr in C++20
@@ -1275,6 +1295,8 @@
#include <__algorithm/ranges_move.h>
#include <__algorithm/ranges_move_backward.h>
#include <__algorithm/ranges_none_of.h>
+#include <__algorithm/ranges_remove.h>
+#include <__algorithm/ranges_remove_if.h>
#include <__algorithm/ranges_replace.h>
#include <__algorithm/ranges_replace_if.h>
#include <__algorithm/ranges_reverse.h>