| 14 | namespace NPrivate { |
| 15 | template <class I, class F, class P> |
| 16 | constexpr I ExtremeElementBy(I begin, I end, F&& func, P&& pred) { |
| 17 | if (begin == end) { |
| 18 | return end; |
| 19 | } |
| 20 | |
| 21 | auto bestValue = func(*begin); |
| 22 | auto bestPos = begin; |
| 23 | |
| 24 | for (++begin; begin != end; ++begin) { |
| 25 | auto curValue = func(*begin); |
| 26 | if (pred(curValue, bestValue)) { |
| 27 | bestValue = std::move(curValue); |
| 28 | bestPos = begin; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | return bestPos; |
| 33 | } |
| 34 | } // namespace NPrivate |
| 35 | |
| 36 | template <class T> |
no test coverage detected