[libc++][ranges] Implement `ranges::remove_copy{, _if}`.
Co-authored-by: Hui Xie <hui.xie1990@gmail.com>
Differential Revision: https://reviews.llvm.org/D130599
NOKEYCHECK=True
GitOrigin-RevId: 760d2b462c04537d119d76d3cc37d2cb53774a05
diff --git a/include/algorithm b/include/algorithm
index 92e9327..b4e1b82 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -912,6 +912,38 @@
indirectly_copyable_storable<iterator_t<R>, O>)
constexpr unique_copy_result<borrowed_iterator_t<R>, O>
unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using remove_copy_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class T,
+ class Proj = identity>
+ indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
+ constexpr remove_copy_result<I, O>
+ remove_copy(I first, S last, O result, const T& value, Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class T, class Proj = identity>
+ requires indirectly_copyable<iterator_t<R>, O> &&
+ indirect_binary_predicate<ranges::equal_to,
+ projected<iterator_t<R>, Proj>, const T*>
+ constexpr remove_copy_result<borrowed_iterator_t<R>, O>
+ remove_copy(R&& r, O result, const T& value, Proj proj = {}); // Since C++20
+
+ template<class I, class O>
+ using remove_copy_if_result = in_out_result<I, O>; // Since C++20
+
+ template<input_iterator I, sentinel_for<I> S, weakly_incrementable O,
+ class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred>
+ requires indirectly_copyable<I, O>
+ constexpr remove_copy_if_result<I, O>
+ remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // Since C++20
+
+ template<input_range R, weakly_incrementable O, class Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
+ requires indirectly_copyable<iterator_t<R>, O>
+ constexpr remove_copy_if_result<borrowed_iterator_t<R>, O>
+ remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); // Since C++20
+
}
constexpr bool // constexpr in C++20
@@ -1694,6 +1726,8 @@
#include <__algorithm/ranges_pop_heap.h>
#include <__algorithm/ranges_push_heap.h>
#include <__algorithm/ranges_remove.h>
+#include <__algorithm/ranges_remove_copy.h>
+#include <__algorithm/ranges_remove_copy_if.h>
#include <__algorithm/ranges_remove_if.h>
#include <__algorithm/ranges_replace.h>
#include <__algorithm/ranges_replace_if.h>