Procházet zdrojové kódy

Fixed `call of overloaded isinf(double&) is ambiguous` (issue #284)

Benoit Blanchon před 9 roky
rodič
revize
7ebff5949f
2 změnil soubory, kde provedl 29 přidání a 0 odebrání
  1. 1 0
      CHANGELOG.md
  2. 28 0
      include/ArduinoJson/Polyfills/math.hpp

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ HEAD
 
 * Improved speed of float serialization (about twice faster)
 * Added `as<JsonArray>()` as a synonym for `as<JsonArray&>()`... (issue #291)
+* Fixed `call of overloaded isinf(double&) is ambiguous` (issue #284)
 
 v5.6.2
 ------

+ 28 - 0
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>(double x) {
+  return isnanl(x);
+}
+#endif
+
+#if defined(_GLIBCXX_HAVE_ISNANF) && _GLIBCXX_HAVE_ISNANF
+template <>
+inline bool isNaN<float>(float x) {
+  return isnanf(x);
+}
+#endif
+
 template <typename T>
 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>(double x) {
+  return isinfl(x);
+}
+#endif
+
+#if defined(_GLIBCXX_HAVE_ISINFF) && _GLIBCXX_HAVE_ISINFF
+template <>
+inline bool isInfinity<float>(float x) {
+  return isinff(x);
+}
+#endif
+
 #if defined(__GNUC__)
 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
 #pragma GCC diagnostic pop