Function Subspace :: sus :: cmp :: max_by_key

template <class T, class KeyFn, int &... , class Key = std::invoke_result_t<KeyFn &, const std::remove_reference_t<T> &>>
auto max_by_key(T a, T b, KeyFn f) -> T
requires
sus::fn::FnMut<KeyFn, ::sus::fn::NonVoid (const std::remove_reference_t<T> &)>
sus::cmp::Ord<Key>

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.