summaryrefslogtreecommitdiff
path: root/Source/Core/Common/MathUtil.h
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2017-12-26 00:38:44 +0100
committerLéo Lam <leo@innovatetechnologi.es>2019-05-04 23:12:17 +0200
commitab9ece9bcab8a6d55dbe6f3a904d49231e5f73e1 (patch)
tree3993f73a513f6f80ecddff85882042b73da261da /Source/Core/Common/MathUtil.h
parent6f84984b7b0514227327b2e2c5ef10907d150b96 (diff)
Replace MathUtil::Clamp with std::clamp
Diffstat (limited to 'Source/Core/Common/MathUtil.h')
-rw-r--r--Source/Core/Common/MathUtil.h22
1 files changed, 8 insertions, 14 deletions
diff --git a/Source/Core/Common/MathUtil.h b/Source/Core/Common/MathUtil.h
index 990a5dd145..1556f8e39f 100644
--- a/Source/Core/Common/MathUtil.h
+++ b/Source/Core/Common/MathUtil.h
@@ -18,12 +18,6 @@ namespace MathUtil
constexpr double TAU = 6.2831853071795865;
constexpr double PI = TAU / 2;
-template <class T>
-constexpr T Clamp(const T val, const T& min, const T& max)
-{
- return std::max(min, std::min(max, val));
-}
-
template <typename T>
constexpr auto Sign(const T& val) -> decltype((T{} < val) - (val < T{}))
{
@@ -81,20 +75,20 @@ struct Rectangle
// this Clamp.
void ClampLL(T x1, T y1, T x2, T y2)
{
- left = Clamp(left, x1, x2);
- right = Clamp(right, x1, x2);
- top = Clamp(top, y2, y1);
- bottom = Clamp(bottom, y2, y1);
+ left = std::clamp(left, x1, x2);
+ right = std::clamp(right, x1, x2);
+ top = std::clamp(top, y2, y1);
+ bottom = std::clamp(bottom, y2, y1);
}
// If the rectangle is in a coordinate system with an upper-left origin,
// use this Clamp.
void ClampUL(T x1, T y1, T x2, T y2)
{
- left = Clamp(left, x1, x2);
- right = Clamp(right, x1, x2);
- top = Clamp(top, y1, y2);
- bottom = Clamp(bottom, y1, y2);
+ left = std::clamp(left, x1, x2);
+ right = std::clamp(right, x1, x2);
+ top = std::clamp(top, y1, y2);
+ bottom = std::clamp(bottom, y1, y2);
}
};