On GCC, The following gives me an error: no type named 'x' in 'struct Type'
On VC++, It complains about p being undeclared
struct Type
{
static int const x = 0;
};
template <class T> void Func()
{
typename T::x * p; // p to be pointer
}
int main()
{
Func<Type>();
}
T::xbecomesType::x, which is anint, not a type.You’ve told the compiler that
T::xnames a type by usingtypename. WhenFunc<Type>is instantiated,T::xis not a type, so the compiler reports an error.