おそらく異なる長さのインデックスの2つのシーケンスのデカルト積を行う、人気のあるインデックスのトリックのバリアントが必要です。これがどのように行われるかについてのヒント/例を教えてください。ライブラリへのリンクかもしれません。
編集:私はこれを思い付くことができました:
template <typename ...T> struct list {};
template <typename T, typename U>
struct pair
{
typedef T first;
typedef U second;
};
template <std::size_t i>
using index = std::integral_constant<std::size_t, i>;
template <std::size_t ON, std::size_t M, std::size_t N, typename ...Ps>
struct cartesian
: std::conditional<bool(N),
cartesian<ON, M, N - 1, pair<index<M>, index<N> >, Ps...>,
cartesian<ON, M - 1, ON, pair<index<M>, index<N> >, Ps...>
>::type
{
};
template <std::size_t ON, typename ...Ps>
struct cartesian<ON, 0, 0, Ps...>
: list<pair<index<0>, index<0> >, Ps...>
{
};
template <std::size_t M, std::size_t N>
struct make_cartesian : cartesian<N - 1, M - 1, N - 1>
{
static_assert(M > 0, "M has to be greater than 0");
static_assert(N > 0, "N has to be greater than 0");
};