ΒΆtemplate <class T,
class KeyFn,
int&...,
class Key = std::invoke_result_t<
KeyFn&,
const std::remove_reference_t<T>&>>
constexpr T max_by_key(T a, T b, KeyFn f) noexcept
template <class T,
class KeyFn,
int&...,
class Key = std::invoke_result_t<
KeyFn&,
const std::remove_reference_t<T>&>>
constexpr T max_by_key(T a, T b, KeyFn f) noexcept
Description
Returns the element that gives the maximum value from the specified function. Returns the second argument if the comparison determines them to be equal. By default this receives and returns objects by value. To receive and return references, specify the type parameter, such as: `sus::cmp::max_by_key <i32 & >(a, b, k)`. Note that if either input is a temporary object this can return a reference to an object past its lifetime.
Declared at: sus/cmp/ord.h:264
Templates
- T
- KeyFn
- int &
- Key
Parameters
- T a
- T b
- KeyFn f