[llvm] r358893 - STLExtras: add stable_sort wrappers

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 08:19:13 PDT 2019


Author: maskray
Date: Mon Apr 22 08:19:13 2019
New Revision: 358893

URL: http://llvm.org/viewvc/llvm-project?rev=358893&view=rev
Log:
STLExtras: add stable_sort wrappers

Modified:
    llvm/trunk/include/llvm/ADT/STLExtras.h

Modified: llvm/trunk/include/llvm/ADT/STLExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=358893&r1=358892&r2=358893&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/STLExtras.h Mon Apr 22 08:19:13 2019
@@ -1305,6 +1305,16 @@ auto upper_bound(R &&Range, T &&Value, 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.




More information about the llvm-commits mailing list