summaryrefslogtreecommitdiff
path: root/zen/stl_tools.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2018-07-29 21:45:13 -0700
committerDaniel Wilhelm <shieldwed@outlook.com>2018-07-29 21:45:13 -0700
commit06c99e6c91d87a91f3e54191670d23e3f4d132b9 (patch)
treea2c82149d6fe802c68365f73e11f3c241c95ef3d /zen/stl_tools.h
parent10.1 (diff)
downloadFreeFileSync-06c99e6c91d87a91f3e54191670d23e3f4d132b9.tar.gz
FreeFileSync-06c99e6c91d87a91f3e54191670d23e3f4d132b9.tar.bz2
FreeFileSync-06c99e6c91d87a91f3e54191670d23e3f4d132b9.zip
10.2
Diffstat (limited to 'zen/stl_tools.h')
-rwxr-xr-xzen/stl_tools.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/zen/stl_tools.h b/zen/stl_tools.h
index 2ce2cf33..7365392f 100755
--- a/zen/stl_tools.h
+++ b/zen/stl_tools.h
@@ -43,8 +43,8 @@ template <class T, class Alloc>
void removeDuplicates(std::vector<T, Alloc>& v);
//binary search returning an iterator
-template <class ForwardIterator, class T, typename CompLess>
-ForwardIterator binary_search(ForwardIterator first, ForwardIterator last, const T& value, CompLess less);
+template <class Iterator, class T, typename CompLess>
+Iterator binary_search(Iterator first, Iterator last, const T& value, CompLess less);
template <class BidirectionalIterator, class T>
BidirectionalIterator find_last(BidirectionalIterator first, BidirectionalIterator last, const T& value);
@@ -125,9 +125,11 @@ void removeDuplicates(std::vector<T, Alloc>& v)
}
-template <class ForwardIterator, class T, typename CompLess> inline
-ForwardIterator binary_search(ForwardIterator first, ForwardIterator last, const T& value, CompLess less)
+template <class Iterator, class T, typename CompLess> inline
+Iterator binary_search(Iterator first, Iterator last, const T& value, CompLess less)
{
+ static_assert(std::is_same_v<typename std::iterator_traits<Iterator>::iterator_category, std::random_access_iterator_tag>);
+
first = std::lower_bound(first, last, value, less);
if (first != last && !less(value, *first))
return first;
bgstack15