From 1c46bdb959c34390b63c3953d8fc921c86359f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 7 Apr 2020 19:28:48 +0200 Subject: [PATCH] Math: move clamp() definition from Functions.h to Vector.h. Need it for angle(). --- src/Magnum/Math/Functions.h | 5 ++--- src/Magnum/Math/Vector.h | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Magnum/Math/Functions.h b/src/Magnum/Math/Functions.h index db45dc55b..be66b12d0 100644 --- a/src/Magnum/Math/Functions.h +++ b/src/Magnum/Math/Functions.h @@ -318,9 +318,8 @@ set to @p max. Equivalent to: NaNs passed in @p value parameter are propagated. @see @ref min(), @ref max() */ -template inline typename std::enable_if::value, T>::type clamp(T value, T min, T max) { - return Math::min(Math::max(value, min), max); -} +/* defined in Vector.h */ +template constexpr typename std::enable_if::value, T>::type clamp(T value, T min, T max); /** @overload */ template inline Vector clamp(const Vector& value, const Vector& min, const Vector& max) { diff --git a/src/Magnum/Math/Vector.h b/src/Magnum/Math/Vector.h index 6a0ffc8f2..2ed8aa18d 100644 --- a/src/Magnum/Math/Vector.h +++ b/src/Magnum/Math/Vector.h @@ -56,6 +56,9 @@ template constexpr typename std::enable_if::value, T>::type template constexpr typename std::enable_if::value, T>::type max(T value, T max) { return value < max ? max : value; } +template constexpr typename std::enable_if::value, T>::type clamp(T value, T min, T max) { + return Math::min(Math::max(value, min), max); +} #endif namespace Implementation {