[llvm] r342102 - STLExtras: Add some more algorithm wrappers
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 12 17:02:03 PDT 2018
Author: dblaikie
Date: Wed Sep 12 17:02:03 2018
New Revision: 342102
URL: http://llvm.org/viewvc/llvm-project?rev=342102&view=rev
Log:
STLExtras: Add some more algorithm 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=342102&r1=342101&r2=342102&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/STLExtras.h Wed Sep 12 17:02:03 2018
@@ -977,6 +977,10 @@ inline void sort(IteratorTy Start, Itera
std::sort(Start, End);
}
+template <typename Container> inline void sort(Container &&C) {
+ llvm::sort(adl_begin(C), adl_end(C));
+}
+
template <typename IteratorTy, typename Compare>
inline void sort(IteratorTy Start, IteratorTy End, Compare Comp) {
#ifdef EXPENSIVE_CHECKS
@@ -986,6 +990,11 @@ inline void sort(IteratorTy Start, Itera
std::sort(Start, End, Comp);
}
+template <typename Container, typename Compare>
+inline void sort(Container &&C, Compare Comp) {
+ llvm::sort(adl_begin(C), adl_end(C), Comp);
+}
+
//===----------------------------------------------------------------------===//
// Extra additions to <algorithm>
//===----------------------------------------------------------------------===//
@@ -1137,6 +1146,11 @@ auto upper_bound(R &&Range, ForwardIt I)
return std::upper_bound(adl_begin(Range), adl_end(Range), I);
}
+template <typename R, typename ForwardIt, typename Compare>
+auto upper_bound(R &&Range, ForwardIt I, Compare C)
+ -> decltype(adl_begin(Range)) {
+ return std::upper_bound(adl_begin(Range), adl_end(Range), I, C);
+}
/// Wrapper function around std::equal to detect if all elements
/// in a container are same.
template <typename R>
More information about the llvm-commits
mailing list