, , , , , , .
#include <iostream>
struct A {
template<typename T>
static A f(T) {
return A();
}
template<typename T> operator T() { return T(); }
};
template<typename U>
int g() {
U u;
typedef A (*funcPtrType)(int());
return !(funcPtrType)u.f < int() > (0);
}
int main() {
std::cout << g<A>() << std::endl;
}
0 template. f < int() >, 1.
funcPtrType temp1 = (funcPtrType)u.f;
bool temp2 = !temp1;
bool temp3 = temp2 < int();
bool temp4 = temp3 > (0);
return temp4;
A temp1 = u.template f < int() > (0);
funcPtrType temp2 = (funcPtrType) temp1;
bool temp3 = !temp2;
return temp3;
Note that temp2is a null pointer (created return T()). All different analysis, and both are valid! This is really necessary to disambiguate - that you need to insert a keyword template, if necessary.
source
share