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 <
Here's another solution.
#include
#include
#include
template struct typelist { };
template struct typepair { };
template struct product;
template struct append;
template
struct append, typelist> {
typedef typelist type;
};
template<>
struct product, typelist<>> {
typedef typelist<> type;
};
template
struct product, typelist> {
typedef typelist<> type;
};
template
struct product, typelist<>> {
typedef typelist<> type;
};
template
struct product, typelist> {
typedef typename
append,
typepair...,
typepair...>,
typename product, typelist>::type>::type type;
};
int main(void)
{
int s;
std::cout << abi::__cxa_demangle(
typeid(product, typelist>::type).name(), 0, 0, &s) << "\n";
return 0;
}