ΒΆtemplate <class T>
constexpr T clamp(T v, T min, T max) noexcept
template <class T>
constexpr T clamp(T v, T min, T max) noexcept
Description
Restrict a value to a certain interval. Returns `max` if `v` is greater than `max`, and `min` if `v` is less than `min`. Otherwise this returns `v`. By default this receives and returns objects by value. To receive and return references, specify the type parameter, such as: `sus::cmp::clamp <i32 & >(a, min, max)`. Note that if any input is a temporary object this can return a reference to an object past its lifetime. # Panics Panics if `min > max`.
Declared at: sus/cmp/ord.h:283
Templates
- T
Parameters
- T v
- T min
- T max