在像下面这样的模板中,如何从另一个更复杂的元组中的元素填充元组?
template<typename... Ts>
struct foo {
std::tuple<std::vector<Ts>...> tuple;
foo() {
//populate tuple somehow
//assume that no vector is empty
}
void func() {
std::tuple<Ts...> back_tuple; // = ...
//want to populate with the last elements ".back()" of each vector
//how?
}
};
我找不到任何用于元组的 push_back 机制,所以我不确定如何使用模板循环技巧来做到这一点。此外,我找不到任何 initializer_list 之类的模板,用于不同类型来收集我的值,然后传递到新的元组中。有任何想法吗?