4#ifndef TETL_ALGORITHM_CLAMP_HPP
5#define TETL_ALGORITHM_CLAMP_HPP
7#include <etl/_functional/less.hpp>
17template <
typename Type,
typename Compare>
18[[nodiscard]]
constexpr auto clamp(Type
const& v, Type
const& lo, Type
const& hi, Compare comp) -> Type
const&
20 return comp(v, lo) ? lo : comp(hi, v) ? hi : v;
23template <
typename Type>
24[[nodiscard]]
constexpr auto clamp(Type
const& v, Type
const& lo, Type
const& hi)
noexcept -> Type
const&
26 return etl::clamp(v, lo, hi,
etl::
less<Type>());
constexpr auto clamp(Type const &v, Type const &lo, Type const &hi, Compare comp) -> Type const &
If v compares less than lo, returns lo; otherwise if hi compares less than v, returns hi; otherwise r...
Definition clamp.hpp:18
constexpr auto clamp(Type const &v, Type const &lo, Type const &hi) noexcept -> Type const &
If v compares less than lo, returns lo; otherwise if hi compares less than v, returns hi; otherwise r...
Definition clamp.hpp:24
Definition adjacent_find.hpp:9
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:15