Function Subspace :: sus :: cmp :: clamp

template <class T>
auto clamp(T v, T min, T max) -> T
requires
sus::cmp::Ord<T>

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.