STLExtras: Add some more algorithm wrappers

llvm-svn: 342102
This commit is contained in:
David Blaikie 2018-09-13 00:02:03 +00:00
parent eee709f03c
commit 911907ca3c
1 changed files with 14 additions and 0 deletions

View File

@ -977,6 +977,10 @@ inline void sort(IteratorTy Start, IteratorTy End) {
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, IteratorTy End, Compare Comp) {
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) -> decltype(adl_begin(Range)) {
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>