E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ max_element

auto eve::algo::max_element = function_with_traits<max_element_>[default_simple_algo_traits]
inlineconstexpr

#include <eve/module/algo/algo/max_element.hpp>

Note
if you just need a value and not position, use eve::algo::max_value.

By default unrolls by 4 and aligned all memory accesses.

Note
for equivalent elements we return the second amoung equal. std::max_element* returns first but this is more correct and this is also what !std::minmax_elementwill return as max. ! ! @note we assume thateve::is_lessdefined for your type is total order. ! (this comes up when switching min with max) ! ! **Alternative Header** ! ! @code //! #include <eve/algo.hpp> //! @endcode ! ! @groupheader{Callable Signatures} ! @code //! namespace eve::algo //! { //! template<relaxed_range Rng, typename Less> //! auto max_element(Rng&& rng, Less less) -> unaligned_iterator_t<Rng>; // 1 //! //! template<relaxed_range Rng> //! auto max_element(Rng&& rng) -> unaligned_iterator_t<Rng>; // 2 //! } //! @endcode ! ! 1. Returns the position of a maximum value, according to less. ! If the range is empty - returns past the end. ! ! 2. Same as 1 but the less iseve::is_less ! ! **Parameters** ! ! *rng: Relaxed input range to process ! *less: SIMD strict weak ordering. ! ! **Return value** ! ! iterator to max element (end if the range is empty). ! ! @groupheader{Example} ! ! @godbolt{doc/algo/max.cpp} ! ! @seemax_value ! @seemin_element`