[llvm] Revert "[STLExtras] Remove incorrect hack to make indexed_accessor_range operator== compatible with C++20" (PR #72265)

Utkarsh Saxena via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 07:07:15 PST 2023


https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/72265

Reverts llvm/llvm-project#72220

This breaks C++20 build bot. Need to see if upgrading to clang-17 in the build bot would solve the issue.

>From 1445f344331e145566c9fae801b096e651966460 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena <usx at google.com>
Date: Tue, 14 Nov 2023 16:06:21 +0100
Subject: [PATCH] Revert "[STLExtras] Remove incorrect hack to make
 indexed_accessor_range operator== compatible with C++20 (#72220)"

This reverts commit 2be3fcab0e792d934698d5f6af7b7e17d8848ca4.
---
 llvm/include/llvm/ADT/STLExtras.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index e42b0e8d1b27b71..18bc4d108b156bf 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1291,11 +1291,15 @@ class indexed_accessor_range_base {
   }
 
   /// Compare this range with another.
-  template <typename OtherT> bool operator==(const OtherT &rhs) const {
-    return std::equal(begin(), end(), rhs.begin(), rhs.end());
-  }
-  template <typename OtherT> bool operator!=(const OtherT &rhs) const {
-    return !(*this == rhs);
+  template <typename OtherT>
+  friend bool operator==(const indexed_accessor_range_base &lhs,
+                         const OtherT &rhs) {
+    return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
+  }
+  template <typename OtherT>
+  friend bool operator!=(const indexed_accessor_range_base &lhs,
+                         const OtherT &rhs) {
+    return !(lhs == rhs);
   }
 
   /// Return the size of this range.



More information about the llvm-commits mailing list