From 42ca72bf3a161cf8d5e43f5d4f68aeeec3f7e6b4 Mon Sep 17 00:00:00 2001
From: Kent Ross <k@mad.cash>
Date: Thu, 3 Nov 2022 20:17:41 -0700
Subject: [PATCH 6/9] do not define operator!= in C++20

A change to the semantics of equality operator rewriting in C++20 (P2468R2: The Equality Operator You Are Looking For) means that operator== may not be rewritten with reversed operands if operator!= is also defined. Since operator!= can normally be synthesized from operator== regardless in this language standard, we can and should avoid defining those when the new language semantics are available.

This fixes the compilation of tests (and probably consuming code) in C++20 onwards for compilers that implement this new semantic, including recent nightly builds of clang-16.

Reference: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2468r2.html
---
 include/rapidjson/document.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h
index 46510f85..8b0446db 100644
--- a/include/rapidjson/document.h
+++ b/include/rapidjson/document.h
@@ -912,6 +912,7 @@ public:
     */
     template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,internal::IsGenericValue<T> >), (bool)) operator==(const T& rhs) const { return *this == GenericValue(rhs); }
 
+#ifndef __cpp_impl_three_way_comparison
     //! Not-equal-to operator
     /*! \return !(*this == rhs)
      */
@@ -926,7 +927,6 @@ public:
      */
     template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& rhs) const { return !(*this == rhs); }
 
-#ifndef __cpp_impl_three_way_comparison
     //! Equal-to operator with arbitrary types (symmetric version)
     /*! \return (rhs == lhs)
      */
-- 
2.45.2

