Fix indexing below lower bound due to bin. search

This commit is contained in:
Sterling Harper 2018-10-05 22:49:29 -04:00
parent 08a8d3288f
commit 0792781dc5

View file

@ -14,6 +14,7 @@ template<class It, class T>
typename std::iterator_traits<It>::difference_type
lower_bound_index(It first, It last, const T& value)
{
if (*first == value) return 0;
It index = std::lower_bound(first, last, value) - 1;
return (index == last) ? -1 : index - first;
}