mirror of
https://github.com/nlohmann/json.git
synced 2026-07-09 20:15:12 +00:00
d0a43141ea
* Fix #3868: Remove operator!= to enable P2468R2 rewritten candidate synthesis Under C++20 P2468R2, a hand-written operator!= suppresses the compiler's rewritten-candidate synthesis for operator==, preventing heterogeneous comparisons like `std::string s; json j; s == j;` from compiling. Fix by removing the hand-written operator!=, allowing the compiler to synthesize != as !(a==b) in all language modes (C++20 member functions and pre-C++20 friend functions). Behavior change: operator!= now returns !(a==b) unconditionally, including for special values like NaN and discarded. This means: - NaN != NaN now returns true (matches IEEE-754 semantics) - discarded != x now returns true for any x (matches !(discarded == x)) This also fixes underlying defects in previously-working code: - Restores direct == comparison for views vs json (reverts std::ranges::equal workaround added in PR #3950 to dodge this bug) - Re-enables std::string == json comparisons (uncomments check in unit-constructor1.cpp) Fixes: #3868, #3979 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Niels Lohmann <mail@nlohmann.me> * 🎓 fix warning Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>