I've read posts on this topic. But I still having problem when I try to do this.
template<typename T> struct argument_type;
template<typename T, typename U> struct argument_type<T(U)> { typedef U type; };
#define TEST_TYPE2(who) typename animal < argument_type<T(who)>::type >
template<typename T, typename T2>
struct Pig
{
typedef TEST_TYPE2(int) type;
};
I'll get compile error
warning C4346: 'argument_type<T(int)>::type' : dependent name is not a type
prefix with 'typename' to indicate a type
see reference to class template instantiation 'Pig<T,T2>' being compiled
error C2923: 'animal' : 'argument_type<T(int)>::type' is not a valid template type argument for parameter 'T'
However, if I change
#define TEST_TYPE2(who) typename animal < argument_type<T(who)>::type >
to below
#define TEST_TYPE2(who) typename argument_type<T(who)>::type
It compiles fine. It seems that the compiler is unable to recognize the "::type" after i put it inside the <> brackets.
What can I do to make it work?