diff --git a/include/openmc/search.h b/include/openmc/search.h index 3a6f9789d..f22cc1858 100644 --- a/include/openmc/search.h +++ b/include/openmc/search.h @@ -16,16 +16,14 @@ typename std::iterator_traits::difference_type lower_bound_index( { if (*first == value) return 0; - It index = std::lower_bound(first, last, value) - 1; - return (index == last) ? -1 : index - first; + return std::lower_bound(first, last, value) - first - 1; } template typename std::iterator_traits::difference_type upper_bound_index( It first, It last, const T& value) { - It index = std::upper_bound(first, last, value) - 1; - return (index == last) ? -1 : index - first; + return std::upper_bound(first, last, value) - first - 1; } } // namespace openmc