Listing 1

#include <Typelist.h>

// The outer class aggregates all types collected thus far.
template< class HEAD, class TAIL >
struct GenTypelistHelper
{
    // Construct the typelist by appending the new TAIL
    // type to the typelist described in HEAD.
    typedef typename ::Loki::TL::Append<
        typename HEAD::Typelist, TAIL >::Result Typelist;

    // The inner class inherits from the outer,
    // so that the chain can continue.
    template< class NEXT >
    struct Add : GenTypelistHelper<
        GenTypelistHelper< HEAD, TAIL >, NEXT >
    {
    };
};
// Start with an empty typelist.
struct GenTypelistStart
{
    typedef ::Loki::NullType Typelist;
};

// Get the chain started with the first type.
template< class FIRST >
struct GenTypelist :
    GenTypelistHelper< GenTypelistStart, FIRST >
{
};