diff --git a/modules/core/test/ref_reduce_arg.impl.hpp b/modules/core/test/ref_reduce_arg.impl.hpp index 22b7c2b7a6..2e44532f50 100644 --- a/modules/core/test/ref_reduce_arg.impl.hpp +++ b/modules/core/test/ref_reduce_arg.impl.hpp @@ -12,6 +12,21 @@ namespace cvtest { +// Standard library (technically) forbids using std::min_element +// with non-strict std::less_equal, so we make our own min_element +template +Iter custom_min_element(Iter begin, Iter end, Comp cmp_less) +{ + if (begin == end) + return begin; + Iter result = begin; + while (++begin != end) + if (cmp_less(*begin, *result)) + result = begin; + return result; +} + + template struct reduceMinMaxImpl { @@ -30,7 +45,7 @@ struct reduceMinMaxImpl cv::Mat sub = src(idx); auto begin = sub.begin(); - auto it = std::min_element(begin, sub.end(), cmp); + auto it = custom_min_element(begin, sub.end(), cmp); *dst(idx).ptr() = static_cast(std::distance(begin, it)); for (int j = static_cast(idx.size()) - 1; j >= 0; --j)