llvm/llvm-project
在 GitHub 查看[clang] [C++20] Defaulted `operator==` doesn't lookup in using-directive properly
Open
#97,087 建立於 2024年6月28日
clang:frontendgood first issue
倉庫指標
- Star
- (26,378 star)
- PR 合併指標
- (平均合併 1天 2小時) (30 天內合併 1,000 個 PR)
描述
https://godbolt.org/z/c8v65nGzc
struct X {};
namespace NS {
bool operator==(X, X);
}
using namespace NS;
struct Y {
X x;
friend bool operator==(Y, Y);
};
bool operator==(Y, Y) = default;
<source>:10:6: error: defaulting this equality comparison operator would delete it after its first declaration
10 | bool operator==(Y, Y) = default;
| ^
<source>:7:7: note: defaulted 'operator==' is implicitly deleted because there is no viable 'operator==' for member 'x'
7 | X x;
| ^
If it is defaulted in the class it does compile and properly call NS::operator==(X, X): https://godbolt.org/z/M8Msc8T3a
If the function-body is replaced it also compiles: https://godbolt.org/z/19sEre7KW