I\'ve been playing with clang a while, and I stumbled upon \"test/SemaTemplate/dependent-template-recover.cpp\" (in the clang distribution) which is supposed to provide hint
In addition to the points others made, notice that sometimes the compiler couldn't make up his mind and both interpretations can yield alternative valid programs when instantiating
#include
template
struct A {
typedef int R();
template
static U *f(int) {
return 0;
}
static int f() {
return 0;
}
};
template
bool g() {
A a;
return !(typename A::R*)a.f(0);
}
int main() {
std::cout << g() << std::endl;
}
This prints 0 when omitting template before f but 1 when inserting it. I leave it as an exercise to figure out what the code does.