summaryrefslogtreecommitdiff
path: root/include/util/TypeList.hpp
blob: bc8c49bd78b5ea396ea720c828c53097d17900f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef __TYPELIST_H
#define __TYPELIST_H

class NullType {};

template< class T, class U >
struct TypeList {
	typedef T Head;
	typedef U Tail;
};

#define TYPELIST_1( T1 ) TypeList< T1, NullType >
#define TYPELIST_2( T1, T2 ) TypeList< T1, TYPELIST_1( T2 ) >
#define TYPELIST_3( T1, T2, T3 ) TypeList< T1, TYPELIST_2( T2, T3 ) >
#define TYPELIST_4( T1, T2, T3, T4 ) TypeList< T1, TYPELIST_3( T2, T3, T4 ) >

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 };
};

#endif