Skip to content

Commit 2be3fca

Browse files
authored
[STLExtras] Remove incorrect hack to make indexed_accessor_range operator== compatible with C++20 (#72220)
This partially reverts c312f02 The motivation behind this is unclear and the change predates the clang [implementation](38b9d31) of [p2468r2](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 for fixing #70210. It also helps in making sure that older compilers still compile LLVM (in C++20).
1 parent 8cccda2 commit 2be3fca

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,15 +1291,11 @@ class indexed_accessor_range_base {
12911291
}
12921292

12931293
/// Compare this range with another.
1294-
template <typename OtherT>
1295-
friend bool operator==(const indexed_accessor_range_base &lhs,
1296-
const OtherT &rhs) {
1297-
return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
1298-
}
1299-
template <typename OtherT>
1300-
friend bool operator!=(const indexed_accessor_range_base &lhs,
1301-
const OtherT &rhs) {
1302-
return !(lhs == rhs);
1294+
template <typename OtherT> bool operator==(const OtherT &rhs) const {
1295+
return std::equal(begin(), end(), rhs.begin(), rhs.end());
1296+
}
1297+
template <typename OtherT> bool operator!=(const OtherT &rhs) const {
1298+
return !(*this == rhs);
13031299
}
13041300

13051301
/// Return the size of this range.

0 commit comments

Comments
 (0)