STLExtras: add stable_sort wrappers
authorFangrui Song <maskray@google.com>
Mon, 22 Apr 2019 15:19:13 +0000 (15:19 +0000)
committerFangrui Song <maskray@google.com>
Mon, 22 Apr 2019 15:19:13 +0000 (15:19 +0000)
llvm-svn: 358893

llvm/include/llvm/ADT/STLExtras.h

index d63b819715c53f5f1d86904360cd65e2dc148ffc..33aced92e3e58d233615f9f886478e269b6b46c6 100644 (file)
@@ -1305,6 +1305,16 @@ auto upper_bound(R &&Range, T &&Value, Compare C)
                           std::forward<T>(Value), C);
 }
 
+template <typename R>
+void stable_sort(R &&Range) {
+  std::stable_sort(adl_begin(Range), adl_end(Range));
+}
+
+template <typename R, typename Compare>
+void stable_sort(R &&Range, Compare C) {
+  std::stable_sort(adl_begin(Range), adl_end(Range), C);
+}
+
 /// Binary search for the first index where a predicate is true.
 /// Returns the first I in [Lo, Hi) where C(I) is true, or Hi if it never is.
 /// Requires that C is always false below some limit, and always true above it.