diff options
Diffstat (limited to 'include/util/TypeList.hpp')
-rw-r--r-- | include/util/TypeList.hpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/util/TypeList.hpp b/include/util/TypeList.hpp new file mode 100644 index 0000000..bc8c49b --- /dev/null +++ b/include/util/TypeList.hpp @@ -0,0 +1,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 |