Skip to content

Commit

Permalink
Fixed call of overloaded isinf(double&) is ambiguous (issue #284)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Jul 19, 2016
1 parent 4340805 commit 7ebff59
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------
Expand Down
28 changes: 28 additions & 0 deletions include/ArduinoJson/Polyfills/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7ebff59

Please sign in to comment.