Blob Blame History Raw
From 4b35480e18af80b9f0f0c3b9013c2e1ab6d5d7c2 Mon Sep 17 00:00:00 2001
From: Ed Catmur <ed@catmur.uk>
Date: Tue, 31 Jan 2023 16:27:04 +0000
Subject: [PATCH] Remove operator!= synthesized by spaceship

An operator!= suppresses the reversed equality comparison candidate generation.

This is visible in clang 16 (rc0 just released) and in gcc trunk (so probably gcc 13).
---
 c++/src/kj/string.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/c++/src/kj/string.h b/c++/src/kj/string.h
index b9221ba8f..eb31bb546 100644
--- a/c++/src/kj/string.h
+++ b/c++/src/kj/string.h
@@ -127,10 +127,14 @@ class StringPtr {
   inline constexpr const char* end() const { return content.end() - 1; }
 
   inline constexpr bool operator==(decltype(nullptr)) const { return content.size() <= 1; }
+#if !__cpp_impl_three_way_comparison
   inline constexpr bool operator!=(decltype(nullptr)) const { return content.size() > 1; }
+#endif
 
   inline bool operator==(const StringPtr& other) const;
+#if !__cpp_impl_three_way_comparison
   inline bool operator!=(const StringPtr& other) const { return !(*this == other); }
+#endif
   inline bool operator< (const StringPtr& other) const;
   inline bool operator> (const StringPtr& other) const { return other < *this; }
   inline bool operator<=(const StringPtr& other) const { return !(other < *this); }