diff --git a/src/ox/std/math.hpp b/src/ox/std/math.hpp index 57a8ea7f9..28f77ec7c 100644 --- a/src/ox/std/math.hpp +++ b/src/ox/std/math.hpp @@ -24,6 +24,12 @@ constexpr const T &max(const T &a, const T &b) noexcept { return a > b ? a : b; } +template +[[nodiscard]] +constexpr const T &clamp(const T &v, const T &lo, const T &hi) noexcept { + return min(ox::max(v, lo), hi); +} + template [[nodiscard]] constexpr I pow(I v, int e) noexcept {