class Nulltype;
template<class T,class U> struct Typelist
{
using Head = T;
using Tail = U;
};
template<class T> struct Length;
template<> struct Length<Nulltype>
{
enum{value = 0};
};
//计算长度
template<class T,class U> struct Length<Typelist<T,U>>
{
enum{value = 1 + Length<U>::value};
};
Length<Typelist<int,Typelist<char,Nulltype>>>::value;//取得非Nulltype个数
Length用递归实现实,书上说不能用迭代代替。等大神!
template<class T,class U> struct Typelist
{
using Head = T;
using Tail = U;
};
template<class T> struct Length;
template<> struct Length<Nulltype>
{
enum{value = 0};
};
//计算长度
template<class T,class U> struct Length<Typelist<T,U>>
{
enum{value = 1 + Length<U>::value};
};
Length<Typelist<int,Typelist<char,Nulltype>>>::value;//取得非Nulltype个数
Length用递归实现实,书上说不能用迭代代替。等大神!