My goal is to construct a function that would transform an array into n-dimensional vector given dimensions as variadic arguments.
For example for two dimensions.
template<T>
vector<vector<T>> from_array(T *array, size_t d1, size_t d2) {
auto v = vector<vector<T>();
v.reserve(d2);
for (n = 0; n < d2; n++) {
vector(array, array + size)
}
}
I've googled for a while and it seems like I want Homogeneous variadic function parameters, but they aren't available in c++. But maybe there's a simpler solution or a workaround?
Also seems like I would need to use decltype
, but my experience with c++ is almost nil, so I'm not sure how to use it.