Open
Description
This program
template <typename T>
class A {
friend void f<>(A);
};
template <typename T>
void f(A<T>) {}
int main() {
f(A<int>{});
}
is accepted in GCC and MSVC starting from C++20. But Clang keeps complaining:
error: no candidate function template was found for dependent friend function template specialization
3 | friend void f<>(A);
| ^
Online demo: https://gcc.godbolt.org/z/vKjhY9WMv
It looks related to ADL changes for function templates lookup with explicitly-specified template arguments in C++20: https://en.cppreference.com/w/cpp/language/adl.html#Notes
GCC and MSVC both allow unqualified names in template friend declaration friend void f<>(A&);
, which is accepted if function template f
is declared after class A
body but before its instantiation.