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

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 07:07:46 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Utkarsh Saxena (usx95)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/72265.diff


1 Files Affected:

- (modified) llvm/include/llvm/ADT/STLExtras.h (+9-5) 


``````````diff
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.

``````````

</details>


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


More information about the llvm-commits mailing list