[llvm] [STLExtras] Remove incorrect hack to make indexed_accessor_range operator== compatible with C++20 (PR #72220)
Utkarsh Saxena via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 23:49:52 PST 2023
https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/72220
This partially reverts c312f025940d79b858166b80c50526558864d54e
The motivation behind this is unclear and the change predates the clang implementation of https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2468r2.html so I am not sure if it was ever intended to work. Rewritten template operators were broken since the beginning.
Moreover, moving away from `friend` would be beneficial as these would only accepted once clang revises its implementation to fix https://github.com/llvm/llvm-project/issues/70210. It also helps in making sure that older compilers still compile LLVM.
>From c56f1dafa573d63563e68e870748ebe9b7ec1b02 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena <usx at google.com>
Date: Tue, 14 Nov 2023 08:42:41 +0100
Subject: [PATCH] remove some hack in C++20
---
llvm/include/llvm/ADT/STLExtras.h | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 18bc4d108b156bf..e42b0e8d1b27b71 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1291,15 +1291,11 @@ class indexed_accessor_range_base {
}
/// Compare this range with another.
- 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);
+ 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);
}
/// Return the size of this range.
More information about the llvm-commits
mailing list