9#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_CLAMP_HPP_
10#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_CLAMP_HPP_
18#include "arene/base/stdlib_choice/enable_if.hpp"
19#include "arene/base/stdlib_choice/less.hpp"
37template <
typename T,
class Compare, constra
ints<std::enable_if_t<is_compare_v<Compare&, T const&>>> =
nullptr>
38constexpr auto clamp(T
const& val, T
const& low, T
const& high, Compare comp)
noexcept(
noexcept(comp(val, low)))
46 if (comp(high, val)) {
61constexpr auto clamp(T
const& val, T
const& low, T
const& high)
noexcept(
noexcept(
std::less<T>{}(val, low)))
63 return ::arene::base::clamp(val, low, high,
std::less<T>{});
Function object that can be invoked for less than comparisons.
Definition less.hpp:32
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Definition accumulate.hpp:37
constexpr auto clamp(T const &val, T const &low, T const &high, Compare comp) noexcept(noexcept(comp(val, low))) -> T const &
Clamp the supplied value between two bounds using the supplied comparator for ordering.
Definition clamp.hpp:38
Definition accumulate.hpp:36