Код: Выделить всё
using namespace std;
template
constexpr auto
for_each(tuple as, F f) {
return apply(
[](auto... xs){
(f(xs), ... );
},
as
);
}
< /code>
Я могу его гнездиться < /p>
template
void g(A a, B b);
template
constexpr auto
run_all(
tuple as,
tuple bs)
{
return for_each(
as,
[bs](auto x){
for_each(
bs,
[x](auto y) {
g(x, y);
}
);
}
);
}
< /code>
Но если я вставлю его в его вложенной версии, я получаю что-то вроде < /p>
template
void g(A a, B b);
template
constexpr auto
run_all(
tuple as,
tuple bs)
{
return apply(
[bs](auto... xs){
(
apply(
[xs](auto... ys){
(g(xs, ys), ...);
},
bs
)
, ...);
},
as
);
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... n-of-packs