Skip to content

Commit 911907c

Browse files
committedSep 13, 2018
STLExtras: Add some more algorithm wrappers
llvm-svn: 342102
1 parent eee709f commit 911907c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎llvm/include/llvm/ADT/STLExtras.h

+14
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,10 @@ inline void sort(IteratorTy Start, IteratorTy End) {
977977
std::sort(Start, End);
978978
}
979979

980+
template <typename Container> inline void sort(Container &&C) {
981+
llvm::sort(adl_begin(C), adl_end(C));
982+
}
983+
980984
template <typename IteratorTy, typename Compare>
981985
inline void sort(IteratorTy Start, IteratorTy End, Compare Comp) {
982986
#ifdef EXPENSIVE_CHECKS
@@ -986,6 +990,11 @@ inline void sort(IteratorTy Start, IteratorTy End, Compare Comp) {
986990
std::sort(Start, End, Comp);
987991
}
988992

993+
template <typename Container, typename Compare>
994+
inline void sort(Container &&C, Compare Comp) {
995+
llvm::sort(adl_begin(C), adl_end(C), Comp);
996+
}
997+
989998
//===----------------------------------------------------------------------===//
990999
// Extra additions to <algorithm>
9911000
//===----------------------------------------------------------------------===//
@@ -1137,6 +1146,11 @@ auto upper_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range)) {
11371146
return std::upper_bound(adl_begin(Range), adl_end(Range), I);
11381147
}
11391148

1149+
template <typename R, typename ForwardIt, typename Compare>
1150+
auto upper_bound(R &&Range, ForwardIt I, Compare C)
1151+
-> decltype(adl_begin(Range)) {
1152+
return std::upper_bound(adl_begin(Range), adl_end(Range), I, C);
1153+
}
11401154
/// Wrapper function around std::equal to detect if all elements
11411155
/// in a container are same.
11421156
template <typename R>

0 commit comments

Comments
 (0)