I was reading the Wikipedia article on SFINAE and encountered following code sample:
struct Test
{
typedef int Type;
};
template < typename T >
void
Basically, you need the typename
keyword when you are writing template code (i.e. you are in a function template or class template) and you are referring to an indentifier that depends on a template parameter that might not be known to be a type, but must be interpreted as a type in your template code.
In your example, you use typename T::Type
at definition #1 because T::Type
depends on the template parameter T
and might otherwise be a data member.
You don't need typename T
at definition #2 as T
is declared to be a type as part of the template definition.