From 435fc32a697188a43c86c559e60069711317ffc9 Mon Sep 17 00:00:00 2001 From: "Andreas C. Osowski" Date: Tue, 24 Apr 2018 21:58:51 +0200 Subject: [PATCH] Fix operator== overload ambiguity --- include/nlohmann/json.hpp | 12 ++++++++---- single_include/nlohmann/json.hpp | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 54e66d90fa..5734f7a67f 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -5533,8 +5533,10 @@ class basic_json @brief comparison: equal @copydoc operator==(const_reference, const_reference) */ - template::value, int>::type = 0> + template < typename ScalarType, typename std::enable_if < + std::is_scalar::value, int >::type = 0, + typename std::enable_if < + std::is_same>::value, int >::type = 0 > friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept { return (lhs == basic_json(rhs)); @@ -5544,8 +5546,10 @@ class basic_json @brief comparison: equal @copydoc operator==(const_reference, const_reference) */ - template::value, int>::type = 0> + template < typename ScalarType, typename std::enable_if < + std::is_scalar::value, int >::type = 0, + typename std::enable_if < + std::is_same>::value, int >::type = 0 > friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept { return (basic_json(lhs) == rhs); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index c9ef7581af..c2e816e82a 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -15174,8 +15174,10 @@ class basic_json @brief comparison: equal @copydoc operator==(const_reference, const_reference) */ - template::value, int>::type = 0> + template < typename ScalarType, typename std::enable_if < + std::is_scalar::value, int >::type = 0, + typename std::enable_if < + !std::is_same>::value, int >::type = 0 > friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept { return (lhs == basic_json(rhs)); @@ -15185,8 +15187,10 @@ class basic_json @brief comparison: equal @copydoc operator==(const_reference, const_reference) */ - template::value, int>::type = 0> + template < typename ScalarType, typename std::enable_if < + std::is_scalar::value, int >::type = 0, + typename std::enable_if < + !std::is_same>::value, int >::type = 0 > friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept { return (basic_json(lhs) == rhs);