Generally, you cannot convert vector to tuple . However, if all you are trying to do is tuple <f(0), f(1), ..., f(N-1)> for some N , which is a constant expression, then this is doable with the sequence trick indexes:
template <typename F, size_t... Is> auto gen_tuple_impl(F func, std::index_sequence<Is...> ) { return std::make_tuple(func(Is)...); } template <size_t N, typename F> auto gen_tuple(F func) { return gen_tuple_impl(func, std::make_index_sequence<N>{} ); }
What we can use as:
For your specific use case, this will be:
auto connections = gen_tuple<6>([&](size_t i) { return new ConvConnection< decltype(inputLayer), decltype(*C1[0]), decltype(*Conn1Opt[0]), RandomInitialization<arma::mat>, arma::mat >(inputLayer, *C1[i], *Conn1Opt[i], 5, 5); });
Barry source share