mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 06:25:30 -04:00
Iterator invalidation in lower/upper_bound_index
Error ocured in regression_tests/filter_mesh/test.py
This commit is contained in:
parent
0cf7d92837
commit
b150a58a11
1 changed files with 2 additions and 4 deletions
|
|
@ -16,16 +16,14 @@ typename std::iterator_traits<It>::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<class It, class T>
|
||||
typename std::iterator_traits<It>::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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue