The typename keyword is needed whenever a type name depends on a template parameter, (so the compiler can 'know' the semantics of an identifier (type or value) without having a full symbol table at the first pass).
Not in the same meaning, and a bit less common, the lone typename keyword can also be useful when using generic template parameters: http://ideone.com/amImX
#include
#include
#include
template class Container,
template class Alloc = std::allocator>
struct ContainerTests
{
typedef Container > IntContainer;
typedef Container > StringContainer;
//
void DoTests()
{
IntContainer ints;
StringContainer strings;
// ... etc
}
};
int main()
{
ContainerTests t1;
ContainerTests t2;
t1.DoTests();
t2.DoTests();
}