Add math::clamp(x, low, high)

This commit is contained in:
Nikita Lisitsa 2026-09-03 12:14:43 +03:00
parent 7f69077c0a
commit 2db6c32310

View file

@ -183,6 +183,14 @@ namespace psemek::math
return (x >= 0) ? std::fmod(x, m) : (m - std::fmod(-x, m));
}
template <typename T>
auto clamp(T const & x, T const & low, T const & high)
{
using std::min;
using std::max;
return min(high, max(low, x));
}
template <typename T>
bool make_min(T & target, T const & source)
{