make use of std::lower_bound and std::upper_bound when build with STL

this assumes that the STL library supports C++11

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2016-09-14 23:46:30 +00:00
parent da72643035
commit 59bf73f74f

View file

@ -351,13 +351,10 @@ inline void qDeleteAll(const Container &c)
namespace QAlgorithmsPrivate {
template <typename RandomAccessIterator, typename T, typename LessThan>
#ifndef QT_NO_STL
Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T & , LessThan lessThan)
#else
Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
#endif
{
#ifndef QT_NO_STL
Q_UNUSED(t);
std::sort(start, end, lessThan);
#else
top:
@ -498,6 +495,9 @@ inline void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator e
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
#ifndef QT_NO_STL
return std::lower_bound(begin, end, value, lessThan);
#else
RandomAccessIterator middle;
int n = int(end - begin);
int half;
@ -513,12 +513,16 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator
}
}
return begin;
#endif
}
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
#ifndef QT_NO_STL
return std::upper_bound(begin, end, value, lessThan);
#else
RandomAccessIterator middle;
int n = end - begin;
int half;
@ -534,6 +538,7 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator
}
}
return begin;
#endif
}
template <typename RandomAccessIterator, typename T, typename LessThan>