Possible Duplicate:
Where and why do I have to put “template” and “typename” on dependent names?
This is a specific instance of the question: Officially, what is typename for?
I am asking for the specific reason that the compiler is NOT aware that the following is a type:
#include <set>
#include <vector>
template<typename T> // T is a type, right?
void f(const char name[], const std::vector<T>& foo) // typename NOT needed here
{
for(std::set<T>::iterator itr = // here, it is needed
If I declare:
std::set<int>::iterator itr; // no problem
The above clearly defines that T
is a type, so why is typename
required in one and not the other?