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
8
9namespace etl {
10
13template <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
22template <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
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
Definition adjacent_find.hpp:8
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:14
etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit...
Definition pair.hpp:36