I\'d like to create the cross product of a list of types using variadic templates.
Here\'s what I have so far:
#include
#include <
Somehow my brain is fried: I think I'm using more code than is needed but, at least, it has the desired results (although I didn't fix the memory leak):
#include
#include
#include
template struct type_list {};
template struct type_pair {};
template
struct row
{
typedef type_list...> type;
};
template struct concat;
template
struct concat, type_list>
{
typedef type_list type;
};
template
struct expand
{
typedef type_list type;
};
template <> struct expand<> { typedef type_list<> type; };
template
struct expand, L...>
{
typedef typename concat::type, typename expand::type>::type type;
};
template
struct cross_product
{
typedef typename expand::type...>>::type type;
};
int main()
{
int s;
typedef cross_product::type result;
std::cout << abi::__cxa_demangle(typeid(result).name(), 0, 0, &s) << std::endl;
return 0;
}