trying to follow this:
http://www.ddj.com/cpp/184403813
all seemed to be going fairly well, but i am afraid my compiler (BCB6) might not be so hot at template deduction.
Code:
template<typename H,typename T>struct typelist
{
typedef H head;
typedef T tail;
};
struct end{};
template<typename T1,typename T2,typename T3,typename T4> struct types;//i had to add this to make dr dobb's example compile at all
template<typename T> struct types<T,end,end,end>
{
typedef typelist<T,end> type;
};
template<typename T1,typename T2>struct types<T1,T2,end,end>
{
typedef
typelist
<
T1,typelist
<
T2,end
>
>
type;
};
template<typename T1,typename T2,typename T3>struct types<T1,T2,T3,end>
{
typedef
typelist
<
T1,typelist
<
T2,typelist
<
T3,end
>
>
>
type;
};
template<typename T1,typename T2,typename T3,typename T4>struct types<T1,T2,T3,T4>
{
typedef
typelist
<
T1,typelist
<
T2,typelist
<
T3,
typelist
<
T4,end
>
>
>
>
type;
};
typedef types<int,char>::type intchar; // compiles until i add this line; error = 'too few arguments passed to types
typedef types<int,char,end,end>::type intchar; // this compiles but does not exactly work like a typelist :(
any ideas what gives? i don't usually second-guess my compiler, but modifying examples to make them compile makes me suspicious.