From 9b07504e2305b81331712b8b4c5b0df9c7dede6a Mon Sep 17 00:00:00 2001 From: Niels Date: Fri, 1 Jan 2016 18:33:58 +0100 Subject: [PATCH] fix for #166 --- README.md | 1 + src/json.hpp | 4 ++-- src/json.hpp.re2c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 91bb1e0d..fff191be 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 82fa3b24..c9fe4ebc 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 0dfa6737..d9d696ae 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