[libc++][ranges] Implement `ranges::stable_sort`.
Differential Revision: https://reviews.llvm.org/D127834
NOKEYCHECK=True
GitOrigin-RevId: 94c7b89fe5b096f85cdddc9c11a1a8112f9409c7
diff --git a/include/algorithm b/include/algorithm
index 62b67c3..0154dbc 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -287,7 +287,6 @@
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20
-
template<bidirectional_iterator I, sentinel_for<I> S>
requires permutable<I>
constexpr I ranges::reverse(I first, S last); // since C++20
@@ -300,12 +299,22 @@
class Proj = identity>
requires sortable<I, Comp, Proj>
constexpr I
- sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+ ranges::sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
template<random_access_range R, class Comp = ranges::less, class Proj = identity>
requires sortable<iterator_t<R>, Comp, Proj>
constexpr borrowed_iterator_t<R>
- sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+ ranges::sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
+ class Proj = identity>
+ requires sortable<I, Comp, Proj>
+ I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
+
+ template<random_access_range R, class Comp = ranges::less, class Proj = identity>
+ requires sortable<iterator_t<R>, Comp, Proj>
+ borrowed_iterator_t<R>
+ ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
template<class T, output_iterator<const T&> O, sentinel_for<O> S>
constexpr O ranges::fill(O first, S last, const T& value); // since C++20
@@ -1252,6 +1261,7 @@
#include <__algorithm/ranges_replace_if.h>
#include <__algorithm/ranges_reverse.h>
#include <__algorithm/ranges_sort.h>
+#include <__algorithm/ranges_stable_sort.h>
#include <__algorithm/ranges_swap_ranges.h>
#include <__algorithm/ranges_transform.h>
#include <__algorithm/ranges_upper_bound.h>