template<typename T>
class CompoundT { // primary template
public:
enum { IsPtrT = 0, IsRefT = 0, IsArrayT = 0,
IsFuncT = 0, IsPtrMemT = 0 };
typedef T BaseT;
typedef T BottomT;
typedef CompoundT<void> ClassT;
};
template<typename T, size_t N>
class CompoundT <T[N]> { // partial specialization for arrays
public:
enum { IsPtrT = 0, IsRefT = 0, IsArrayT = 1,
IsFuncT = 0, IsPtrMemT = 0 };
typedef T BaseT;
typedef typename CompoundT<T>::BottomT BottomT;
typedef CompoundT<void> ClassT;
};
and in main:
template<class T>
bool isArray(T a)
{
return CompoundT<T>::IsArrayT;
}
int _tmain(int argc, _TCHAR* argv[])
{
int a[10];
cout << isArray(a);
return 0;
}
Why this doesn't work? This example is from "Templates the complete guide" ch.19.2.