diff --git a/CHANGELOG.md b/CHANGELOG.md index 7df0d89d..fbaf1a32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ HEAD * Improved speed of float serialization (about twice faster) * Added `as()` as a synonym for `as()`... (issue #291) +* Fixed `call of overloaded isinf(double&) is ambiguous` (issue #284) v5.6.2 ------ diff --git a/include/ArduinoJson/Polyfills/math.hpp b/include/ArduinoJson/Polyfills/math.hpp index b26f6a48..2d08a8e9 100644 --- a/include/ArduinoJson/Polyfills/math.hpp +++ b/include/ArduinoJson/Polyfills/math.hpp @@ -62,6 +62,20 @@ bool isNaN(T x) { return isnan(x); } +#if defined(_GLIBCXX_HAVE_ISNANL) && _GLIBCXX_HAVE_ISNANL +template <> +inline bool isNaN(double x) { + return isnanl(x); +} +#endif + +#if defined(_GLIBCXX_HAVE_ISNANF) && _GLIBCXX_HAVE_ISNANF +template <> +inline bool isNaN(float x) { + return isnanf(x); +} +#endif + template bool isInfinity(T x) { // Workaround for libs that #undef isinf @@ -73,6 +87,20 @@ bool isInfinity(T x) { return isinf(x); } +#if defined(_GLIBCXX_HAVE_ISINFL) && _GLIBCXX_HAVE_ISINFL +template <> +inline bool isInfinity(double x) { + return isinfl(x); +} +#endif + +#if defined(_GLIBCXX_HAVE_ISINFF) && _GLIBCXX_HAVE_ISINFF +template <> +inline bool isInfinity(float x) { + return isinff(x); +} +#endif + #if defined(__GNUC__) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #pragma GCC diagnostic pop