[llvm] [STLExtras] Remove incorrect hack to make indexed_accessor_range operator== compatible with C++20 (PR #72220)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 23:50:23 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-adt
Author: Utkarsh Saxena (usx95)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/72220.diff
1 Files Affected:
- (modified) llvm/include/llvm/ADT/STLExtras.h (+5-9)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/72220
More information about the llvm-commits
mailing list