Code:
template <class T>
void f(){
T::iterator a; // will work using Gcc if we add typename
//...
}
The above code will work using MSVC++ and will not work using gcc, because MSVC++ will delay parsing.
I know that the compiler at the template definition time will only perform lookups for non-dependent names, and since T::iterator obviously depends on T, why does the lookup happen at template defintion time ?
It doesn’t. Dependent names are looked up at instantiation time. At definition time, it only checks for syntax errors, etc. for dependent names. The typename keyword is used to help the compiler parse the expression.