J
Jon Slaughter
I'm having some issues using loki's typelists and I'm wondering if there is
something I'm missing.
I'm trying to create a template who's specialization sorta looks like
template <int I, class T>
struct Node
{
enum {Index = I};
typedef T Class;
};
typedef Node<0, NullClass> NullNode;
template <int I, class T1, class T2>
struct T<I, Typelist<T1, T2> >
: TL::TypeAtNonStrict<Typelist<T1,T2>, TL::IndexOf<Typelist<T1, T2>,
Node<I,*> >::value>, NullNode>::Result::Class
{
.....
the problem is at Node<I,*>, the idea is to search through the Typelist for
the Node that has index corresponding to I and return the class for that
node... the problem is I have to specify *. I've tried to add a
parameterization T3 to the template and replace * with T3 but then it says
T3 is not used. If I specify * to some class then ofcourse it won't work
because it will only match instances in the Typelist that will have that
class too...
Is there any way to do this by getting the template to parameterize * so
that I can only match the Index?
I feel that I will end up having to modify the IndexOf algorithm to work
specifically with Node to compare only the Index value and just pass * a
dummy variable like NullNode that will be ignored. Just wondering if there
is a better way?
Thanks,
Jon
something I'm missing.
I'm trying to create a template who's specialization sorta looks like
template <int I, class T>
struct Node
{
enum {Index = I};
typedef T Class;
};
typedef Node<0, NullClass> NullNode;
template <int I, class T1, class T2>
struct T<I, Typelist<T1, T2> >
: TL::TypeAtNonStrict<Typelist<T1,T2>, TL::IndexOf<Typelist<T1, T2>,
Node<I,*> >::value>, NullNode>::Result::Class
{
.....
the problem is at Node<I,*>, the idea is to search through the Typelist for
the Node that has index corresponding to I and return the class for that
node... the problem is I have to specify *. I've tried to add a
parameterization T3 to the template and replace * with T3 but then it says
T3 is not used. If I specify * to some class then ofcourse it won't work
because it will only match instances in the Typelist that will have that
class too...
Is there any way to do this by getting the template to parameterize * so
that I can only match the Index?
I feel that I will end up having to modify the IndexOf algorithm to work
specifically with Node to compare only the Index value and just pass * a
dummy variable like NullNode that will be ignored. Just wondering if there
is a better way?
Thanks,
Jon