Skip to content

Commit

Permalink
add max_element and min_element
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Nov 3, 2024
1 parent 8bfa7fc commit f76f708
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/utl/helpers/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,14 @@ constexpr bool equal(Collection1&& c1, Collection2&& c2) {
return std::equal(begin(c1), end(c1), begin(c2), end(c2));
}

template <typename Collection, typename Fn>
constexpr auto max_element(Collection&& c, Fn&& fn) {
return std::max_element(begin(c), end(c), std::forward<Fn>(fn));
}

template <typename Collection, typename Fn>
constexpr auto min_element(Collection&& c, Fn&& fn) {
return std::min_element(begin(c), end(c), std::forward<Fn>(fn));
}

} // namespace utl

0 comments on commit f76f708

Please sign in to comment.