[ox/std] Add ox::clamp

This commit is contained in:
Gary Talent 2022-02-03 00:22:37 -06:00
parent 1aebe93c52
commit 78942ce21d

View File

@ -24,6 +24,12 @@ constexpr const T &max(const T &a, const T &b) noexcept {
return a > b ? a : b;
}
template<typename T>
[[nodiscard]]
constexpr const T &clamp(const T &v, const T &lo, const T &hi) noexcept {
return min(ox::max(v, lo), hi);
}
template<typename I>
[[nodiscard]]
constexpr I pow(I v, int e) noexcept {