Why the "typename" in iterator templates?
Lets say you have the following:
Code:
template<class T>
void doSomething(std::list<T> myList)
{
std::list<T>::iterator i;
}
Won't work. You need
Code:
template<class T>
void doSomething(std::list<T> myList)
{
typename std::list<T>::iterator i;
}
I'm assuming that for some reason the meaning of "std::list<T>::iterator" is ambiguous, so you need to tell the compiler you are using it as a typename, but why does using the templates make it ambiguous? What else could it mean to the compiler?