Skip to content

Commit 3f505cd

Browse files
authored
[libc] Mark operator== const to avoid ambiguity in C++20. (#73954)
C++20 will automatically generate an operator== with reversed operand order, which is ambiguous with the written operator== when one argument is marked const and the other isn't. This operator currently triggers -Wambiguous-reversed-operator at several usage sites in libc/test/src/__support/CPP/bitset_test.cpp, starting with line 153.
1 parent e4f951e commit 3f505cd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libc/src/__support/CPP/bitset.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ template <size_t NumberOfBits> struct bitset {
6565
}
6666
}
6767

68-
LIBC_INLINE constexpr bool operator==(const bitset<NumberOfBits> &other) {
68+
LIBC_INLINE constexpr bool
69+
operator==(const bitset<NumberOfBits> &other) const {
6970
for (size_t i = 0; i < NUMBER_OF_UNITS; ++i) {
7071
if (Data[i] != other.Data[i])
7172
return false;

0 commit comments

Comments
 (0)