4#ifndef TETL_ALGORITHM_MINMAX_ELEMENT_HPP
5#define TETL_ALGORITHM_MINMAX_ELEMENT_HPP
7#include <etl/_functional/less.hpp>
8#include <etl/_iterator/iterator_traits.hpp>
9#include <etl/_utility/pair.hpp>
15template <
typename ForwardIt,
typename Compare>
16[[nodiscard]]
constexpr auto minmax_element(ForwardIt first, ForwardIt last, Compare comp) ->
pair<ForwardIt, ForwardIt>
21 if (first == last
or ++first == last) {
25 if (comp(*first, *min)) {
31 while (++first != last) {
33 if (++first == last) {
36 }
else if (
not comp(*i, *max)) {
42 if (comp(*first, *i)) {
43 if (comp(*first, *min)) {
46 if (
not comp(*i, *max)) {
53 if (
not comp(*first, *max)) {
64template <
typename ForwardIt>
65[[nodiscard]]
constexpr auto minmax_element(ForwardIt first, ForwardIt last) ->
pair<ForwardIt, ForwardIt>
67 return etl::minmax_element(first, last,
etl::
less());
constexpr auto minmax_element(ForwardIt first, ForwardIt last) -> pair< ForwardIt, ForwardIt >
Finds the smallest and greatest element in the range [first, last).
Definition minmax_element.hpp:65
constexpr auto minmax_element(ForwardIt first, ForwardIt last, Compare comp) -> pair< ForwardIt, ForwardIt >
Finds the smallest and greatest element in the range [first, last).
Definition minmax_element.hpp:16
Definition adjacent_find.hpp:9
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:15
etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit...
Definition pair.hpp:37