diff --git a/README.md b/README.md index 91bb1e0dc..fff191bec 100644 --- a/README.md +++ b/README.md @@ -386,6 +386,7 @@ I deeply appreciate the help of the following people. - [ZahlGraf](https://github.com/ZahlGraf) added a workaround that allows compilation using Android NDK. - [whackashoe](https://github.com/whackashoe) replaced a function that was marked as unsafe by Visual Studio. - [406345](https://github.com/406345) fixed two small warnings. +- [Glen Fernandes](https://github.com/glenfe) noted a potential portability problem in the `has_mapped_type` function. Thanks a lot for helping out! diff --git a/src/json.hpp b/src/json.hpp index 82fa3b24f..c9fe4ebc5 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -94,9 +94,9 @@ struct has_mapped_type { private: template static char test(typename C::mapped_type*); - template static int test(...); + template static char (&test(...))[2]; public: - enum { value = sizeof(test(0)) == sizeof(char) }; + static constexpr bool value = sizeof(test(0)) == 1; }; /// "equality" comparison for floating point numbers diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 0dfa6737b..d9d696aef 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -94,9 +94,9 @@ struct has_mapped_type { private: template static char test(typename C::mapped_type*); - template static int test(...); + template static char (&test(...))[2]; public: - enum { value = sizeof(test(0)) == sizeof(char) }; + static constexpr bool value = sizeof(test(0)) == 1; }; /// "equality" comparison for floating point numbers