[libc++] Implement ranges::is_sorted{, _until}

Reviewed By: Mordante, var-const, #libc

Spies: libcxx-commits, mgorny

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

NOKEYCHECK=True
GitOrigin-RevId: 11e3ad299feee35d2a8a1291d9155b68636362e6
diff --git a/include/algorithm b/include/algorithm
index 30f647c..864ff1c 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -329,6 +329,22 @@
            indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
     constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {});               // since C++20
 
+  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+           indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
+    constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {});      // since C++20
+
+  template<forward_range R, class Proj = identity,
+           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+    constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {});                // since C++20
+
+  template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
+           indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less>
+    constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {});   // since C++20
+
+  template<forward_range R, class Proj = identity,
+           indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less>
+    constexpr borrowed_iterator_t<R>
+      ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {});                       // since C++20
 }
 
     constexpr bool     // constexpr in C++20
@@ -1062,6 +1078,8 @@
 #include <__algorithm/ranges_for_each.h>
 #include <__algorithm/ranges_for_each_n.h>
 #include <__algorithm/ranges_is_partitioned.h>
+#include <__algorithm/ranges_is_sorted.h>
+#include <__algorithm/ranges_is_sorted_until.h>
 #include <__algorithm/ranges_max.h>
 #include <__algorithm/ranges_max_element.h>
 #include <__algorithm/ranges_min.h>