[libc++][ranges] implement `std::ranges::unique{_copy}`

implement `std::ranges::unique` and `std::ranges::unique_copy`

Differential Revision: https://reviews.llvm.org/D130404

NOKEYCHECK=True
GitOrigin-RevId: 72f57e3a30d597346feec74cf626796b0055680f
diff --git a/include/algorithm b/include/algorithm
index 4fc353a..7b510b5 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -865,6 +865,34 @@
     borrowed_iterator_t<R>
       inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
                     Proj proj = {});                                                               // Since C++20
+
+  template<permutable I, sentinel_for<I> S, class Proj = identity,
+           indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
+    constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {});                    // Since C++20
+
+  template<forward_range R, class Proj = identity,
+           indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
+    requires permutable<iterator_t<R>>
+    constexpr borrowed_subrange_t<R>
+      unique(R&& r, C comp = {}, Proj proj = {});                                                  // Since C++20
+
+  template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity,
+           indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
+    requires indirectly_copyable<I, O> &&
+             (forward_iterator<I> ||
+              (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) ||
+              indirectly_copyable_storable<I, O>)
+    constexpr unique_copy_result<I, O>
+      unique_copy(I first, S last, O result, C comp = {}, Proj proj = {});                         // Since C++20
+
+  template<input_range R, weakly_incrementable O, class Proj = identity,
+           indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to>
+    requires indirectly_copyable<iterator_t<R>, O> &&
+             (forward_iterator<iterator_t<R>> ||
+              (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) ||
+              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
 }
 
     constexpr bool     // constexpr in C++20
@@ -1665,6 +1693,8 @@
 #include <__algorithm/ranges_stable_sort.h>
 #include <__algorithm/ranges_swap_ranges.h>
 #include <__algorithm/ranges_transform.h>
+#include <__algorithm/ranges_unique.h>
+#include <__algorithm/ranges_unique_copy.h>
 #include <__algorithm/ranges_upper_bound.h>
 #include <__algorithm/remove.h>
 #include <__algorithm/remove_copy.h>