From d21abfc35e37082b126e4623a3bdafe16a7d21b0 Mon Sep 17 00:00:00 2001 From: Fredrik Sandhei Date: Sat, 7 Oct 2023 15:26:14 +0200 Subject: [PATCH] Replace scalar type comparison restriction with one extended for compatible types. --- include/nlohmann/json.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index f7fac1fb4..2e733b5d2 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3694,9 +3694,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief comparison: equal /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ - template - requires std::is_scalar_v - bool operator==(ScalarType rhs) const noexcept + 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 { return *this == basic_json(rhs); }