From 5ce5d950645924e0f68ca0e0cceba30f2a9ea272 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 1 Apr 2015 11:48:51 +0100 Subject: [PATCH] Added some template specialisation to the juce_isfinite method, so that it can safely be called for integer types too. --- modules/juce_core/maths/juce_MathsFunctions.h | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/maths/juce_MathsFunctions.h b/modules/juce_core/maths/juce_MathsFunctions.h index 8c876f92e2..a4068a8949 100644 --- a/modules/juce_core/maths/juce_MathsFunctions.h +++ b/modules/juce_core/maths/juce_MathsFunctions.h @@ -345,8 +345,26 @@ const float float_Pi = 3.14159265358979323846f; /** The isfinite() method seems to vary between platforms, so this is a platform-independent function for it. */ -template -inline bool juce_isfinite (FloatingPointType value) +template +inline bool juce_isfinite (NumericType value) noexcept +{ + return true; // Integer types are always finite +} + +template <> +inline bool juce_isfinite (float value) noexcept +{ + #if JUCE_WINDOWS + return _finite (value); + #elif JUCE_ANDROID + return isfinite (value); + #else + return std::isfinite (value); + #endif +} + +template <> +inline bool juce_isfinite (double value) noexcept { #if JUCE_WINDOWS return _finite (value);