File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1212
1313namespace cvtest {
1414
15+ // Standard library (technically) forbids using std::min_element
16+ // with non-strict std::less_equal, so we make our own min_element
17+ template <typename Iter, typename Comp>
18+ Iter custom_min_element (Iter begin, Iter end, Comp cmp_less)
19+ {
20+ if (begin == end)
21+ return begin;
22+ Iter result = begin;
23+ while (++begin != end)
24+ if (cmp_less (*begin, *result))
25+ result = begin;
26+ return result;
27+ }
28+
29+
1530template <class Cmp , typename T>
1631struct reduceMinMaxImpl
1732{
@@ -30,7 +45,7 @@ struct reduceMinMaxImpl
3045 cv::Mat sub = src (idx);
3146
3247 auto begin = sub.begin <T>();
33- auto it = std::min_element (begin, sub.end <T>(), cmp);
48+ auto it = custom_min_element (begin, sub.end <T>(), cmp);
3449 *dst (idx).ptr <int32_t >() = static_cast <int32_t >(std::distance (begin, it));
3550
3651 for (int j = static_cast <int >(idx.size ()) - 1 ; j >= 0 ; --j)
You can’t perform that action at this time.
0 commit comments