tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
minmax.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_ALGORITHM_MINMAX_HPP
4
#define TETL_ALGORITHM_MINMAX_HPP
5
6
#include <
etl/_functional/less.hpp
>
7
#include <
etl/_utility/pair.hpp
>
8
9
namespace
etl
{
10
13
template
<
typename
T,
typename
Compare>
14
[[nodiscard]]
constexpr
auto
minmax
(T
const
& a, T
const
& b, Compare comp) ->
pair<T const&, T const&>
15
{
16
using
return_type =
pair<T const&, T const&>
;
17
return
comp(b, a) ? return_type(b, a) : return_type(a, b);
18
}
19
22
template
<
typename
T>
23
[[nodiscard]]
constexpr
auto
minmax
(T
const
& a, T
const
& b) ->
pair<T const&, T const&>
24
{
25
return
etl::minmax
(a, b,
etl::less
());
26
}
27
28
}
// namespace etl
29
30
#endif
// TETL_ALGORITHM_MINMAX_HPP
etl::minmax
constexpr auto minmax(T const &a, T const &b, Compare comp) -> pair< T const &, T const & >
Returns the lowest and the greatest of the given values.
Definition
minmax.hpp:14
less.hpp
etl
Definition
adjacent_find.hpp:8
pair.hpp
etl::less
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition
less.hpp:14
etl::pair
etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit...
Definition
pair.hpp:36
include
etl
_algorithm
minmax.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0