Use a constexpr min
This commit is contained in:
parent
76561bd186
commit
57868c13db
2 changed files with 5 additions and 5 deletions
|
|
@ -17,25 +17,25 @@
|
||||||
template<class T>
|
template<class T>
|
||||||
constexpr T max(T op1, T op2)
|
constexpr T max(T op1, T op2)
|
||||||
{
|
{
|
||||||
return std::max(op1, op2);
|
return op1 > op2 ? op1 : op2;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
constexpr T max(T op1, Args... rest)
|
constexpr T max(T op1, Args... rest)
|
||||||
{
|
{
|
||||||
return std::max(op1, max(rest...));
|
return max(op1, max(rest...));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
constexpr T min(T op1, T op2)
|
constexpr T min(T op1, T op2)
|
||||||
{
|
{
|
||||||
return std::min(op1, op2);
|
return op1 > op2 ? op2 : op1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
constexpr T min(T op1, Args... rest)
|
constexpr T min(T op1, Args... rest)
|
||||||
{
|
{
|
||||||
return std::min(op1, min(rest...));
|
return min(op1, min(rest...));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public:
|
||||||
constexpr Range() = default;
|
constexpr Range() = default;
|
||||||
constexpr Range(Type start, Type end) noexcept
|
constexpr Range(Type start, Type end) noexcept
|
||||||
: _start(start)
|
: _start(start)
|
||||||
, _end(std::max(start, end))
|
, _end(max(start, end))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue