Overview of typename
The keyword typenamehas two meanings in C ++. typenamecan be used as a replacement for classin the template parameter lists.
template<typename A> class Foo {};
template<class A> class Foo {};
Another reason is more complicated. typenametells the compiler that the dependent name is actually a type.
Consider:
template<typename T>
struct Bar
{
typedef T MyType;
typedef T::Type OtherType;
};
, , T::Type , typedef . T Type , (, ), T::Type -, , T, . T::Type - , standardese . , T , , T ( ), typename.
:
template<typename T>
struct Bar
{
typedef T MyType;
typedef typename T::Type OtherType;
};
, - typename , !