diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index d2788bbd7..68f4f2434 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -684,6 +684,11 @@ inline constexpr bool value_in_range_of(T val) template using bool_constant = std::integral_constant; +#ifdef JSON_HAS_CPP_20 +template +concept CompatibleType = !is_basic_json>::value && is_compatible_type>::value; +#endif + /////////////////////////////////////////////////////////////////////////////// // is_c_string /////////////////////////////////////////////////////////////////////////////// diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 2e733b5d2..84d41ab98 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3694,11 +3694,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief comparison: equal /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ - template < typename CompatibleType, - typename U = detail::uncvref_t, - detail::enable_if_t < - !detail::is_basic_json::value && detail::is_compatible_type::value, int > = 0 > - bool operator==(CompatibleType rhs) const noexcept + template T> + bool operator==(T rhs) const noexcept { return *this == basic_json(rhs); }