typename另一个用法是在模板的定义中（选自The typename keyword (C++ only)）：
Use the keyword typename if you have a qualified name that refers to a type and depends on a template parameter. Only use the keyword typename in template declarations and definitions. Consider the following example:
template<class T> class A
typedef char C;
The statement T::x(y) is ambiguous. It could be a call to function x() with a nonlocal argument y, or it could be a declaration of variable y with type T::x. C++ compiler interprets this statement as a function call. In order for the compiler to interpret this statement as a declaration, you must add the keyword typename to the beginning of T:x(y). The statement A::C d; is ill-formed. The class A also refers to A and thus depends on a template parameter. You must add the keyword typename to the beginning of this declaration:
typename A::C d;
You can also use the keyword typename in place of the keyword class in the template parameter declarations.
A name used in a template declaration or definition and that is dependent on a template-parameter is assumed not to name a type unless the applicable name lookup finds a type name or the name is qualified by the keyword typename.
To make this work, the C++ standard defines a “two-phase name lookup” rule for names in templates. Names inside templates are divided to two types:
Dependent – names that depend on the template parameters but aren’t declared within the template.
Non-dependent – names that don’t depend on the template parameters, plus the name of the template itself and names declared within it.
When the compiler tries to resolve some name in the code, it first decides whether the name is dependent or not, and the resolution process stems from this distinction. While non-dependent names are resolved “normally” – when the template is defined, the resolution for dependent names happens at the point of the template’s instantiation. This is what ensures that a specialization can be noticed correctly in the example above.