Function clamp
Summary
#include "breeze/mathematics/clamp.hpp"
(1) template <typename T>
constexpr T const & clamp(T const &value, T const &low, T const &high)
(2) template <typename T, typename Compare>
constexpr T const & clamp(T const &value, T const &low, T const &high, Compare comp)
Function overload
Synopsis
#include "breeze/mathematics/clamp.hpp"
template <typename T>
constexpr T const & clamp(T const &value, T const &low, T const &high)
Description
An implementation of the clamp()
templates introduced in C++17.
- Precondition
T
shall beLessThanComparable
high
shall be no lower thanlow
- Returns
low
ifvalue
is less thanlow
,high
ifhigh
is less thanvalue
, otherwisevalue
- Complexity
- One or two comparisons.
- Remarks
- Returns a reference to
value
whenvalue
is equivalent to one (or both) of the boundary arguments. - If
NaN
is avoided,T
can be a floating-point type.
- Returns a reference to
Source
Line 44 in breeze/mathematics/clamp.hpp.
Synopsis
#include "breeze/mathematics/clamp.hpp"
template <typename T, typename Compare>
constexpr T const & clamp(T const &value, T const &low, T const &high, Compare comp)
Description
An implementation of the clamp()
templates introduced in C++17.
- Precondition
comp( high, low ) == false
- Returns
low
ifvalue
is less thanlow
,high
ifhigh
is less thanvalue
, otherwisevalue
.- Complexity
- One or two comparisons.
- Remarks
- Returns a reference to
value
whenvalue
is equivalent to one (or both) of the boundary arguments. - If
NaN
is avoided,T
can be a floating-point type.
- Returns a reference to
Source
Line 68 in breeze/mathematics/clamp.hpp.