#pragma once
|
|
|
|
namespace gp{
|
|
template<typename T, typename U, typename ...rest>
|
|
constexpr T min(T first, U second, rest... args)
|
|
{
|
|
if constexpr (sizeof...(args) == 0)
|
|
{
|
|
return first < second ? first : second;
|
|
}
|
|
else
|
|
{
|
|
return min(first < second ? first : second, args...);
|
|
}
|
|
}
|
|
|
|
template<typename T, typename U, typename ...rest>
|
|
constexpr T max(T first, U second, rest... args)
|
|
{
|
|
if constexpr (sizeof...(args) == 0)
|
|
{
|
|
return first > second ? first : second;
|
|
}
|
|
else
|
|
{
|
|
return max(first > second ? first : second, args...);
|
|
}
|
|
}
|
|
|
|
template<typename T>
|
|
constexpr T clamp(T first, T value, T last)
|
|
{
|
|
if(value < first) return first;
|
|
if(value > last) return last;
|
|
return value;
|
|
}
|
|
}
|