From a653131cf038599826166846c2203b4345f2e0b5 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 20 Aug 2021 13:42:49 +0200 Subject: [PATCH] :rotating_light: fix warnings --- include/nlohmann/detail/meta/type_traits.hpp | 9 ++++----- include/nlohmann/json.hpp | 4 +++- single_include/nlohmann/json.hpp | 13 +++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index cd31259fb..5f0c097b7 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -451,20 +451,19 @@ T conditional_static_cast(U value) // helper to check if a type has bucket_count function (and hence can tell a std::map and a std::unordered_map apart) template -class has_bucket_count +struct has_bucket_count { - typedef char one; + using one = char; struct two { - char x[2]; + char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) }; template static one test( decltype(&C::bucket_count) ) ; template static two test(...); - public: - enum { value = sizeof(test(0)) == sizeof(char) }; + enum { value = sizeof(test(nullptr)) == sizeof(char) }; }; } // namespace detail diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 5a44a2d45..e15e2c044 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -422,8 +422,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec // Use transparent comparator if possible, combined with perfect forwarding // on find() and count() calls prevents unnecessary string construction. using object_comparator_t = std::less<>; + using key_equal_t = std::equal_to<>; #else using object_comparator_t = std::less; + using key_equal_t = std::equal_to; #endif /*! @@ -515,7 +517,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec std::unordered_map, - std::equal_to, + key_equal_t, AllocatorType>>, diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index fc15f4cdb..130408ae3 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -3862,20 +3862,19 @@ T conditional_static_cast(U value) // helper to check if a type has bucket_count function (and hence can tell a std::map and a std::unordered_map apart) template -class has_bucket_count +struct has_bucket_count { - typedef char one; + using one = char; struct two { - char x[2]; + char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) }; template static one test( decltype(&C::bucket_count) ) ; template static two test(...); - public: - enum { value = sizeof(test(0)) == sizeof(char) }; + enum { value = sizeof(test(nullptr)) == sizeof(char) }; }; } // namespace detail @@ -17823,8 +17822,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec // Use transparent comparator if possible, combined with perfect forwarding // on find() and count() calls prevents unnecessary string construction. using object_comparator_t = std::less<>; + using key_equal_t = std::equal_to<>; #else using object_comparator_t = std::less; + using key_equal_t = std::equal_to; #endif /*! @@ -17916,7 +17917,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec std::unordered_map, - std::equal_to, + key_equal_t, AllocatorType>>,