From fc191903cc5b4f645b3cb33c808cc5d36a74ecad Mon Sep 17 00:00:00 2001 From: Fredrik Sandhei Date: Tue, 19 Mar 2024 20:57:58 +0100 Subject: [PATCH] Operator for non equality --- include/nlohmann/json.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 77dd000ed..482a99133 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3692,8 +3692,6 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec #endif } - // template::value, int>::type = 0> /// @brief comparison: equal /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ template @@ -3703,6 +3701,15 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return *this == basic_json(rhs); } + /// @brief comparison: not equal + /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ + template + requires detail::json_compatible_type::value + bool operator!=(T rhs) const noexcept + { + return *this != basic_json(rhs); + } + /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ bool operator==(std::nullptr_t rhs) const noexcept {