General Purpose library for Freestanding C++ and POSIX systems
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
735 B

#pragma once
namespace gp{
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, 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>
constexpr T clamp(T first, T value, T last)
{
if(value < first) return first;
if(value > last) return last;
return value;
}
}