15 template <
class T,
class Compare>
16 constexpr
const T&
clamp(
const T& v,
const T& lo,
const T& hi, Compare comp) {
17 return assert(!comp(hi, lo)), comp(v, lo) ? lo : comp(hi, v) ? hi : v;
21 constexpr
const T&
clamp(
const T& v,
const T& lo,
const T& hi) {
26 constexpr
const T&
safeClamp(
const T& v1,
const T& v2,
const T& v3) {
27 const T& min = std::min(v2, v3);
28 const T& max = std::max(v2, v3);
29 return std::min(max, std::max(min, v1));
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
Definition: mathutils.h:16
constexpr const T & safeClamp(const T &v1, const T &v2, const T &v3)
Definition: mathutils.h:26
General utilities.
Definition: assert.cpp:7