I would like to return a multidimensional std::array from my function. The size of the returned array shall be determined by the size of an input argument. Something like:
std::array<std::array<unsigned int, n>, n> foo(std::vector<int> vec){
unsigned int n = vec.size;
std::array<std::array<unsigned int, n>, n> result;
return result;
}
It would be nice to solve this without an annoying additional template argument. std::vector instead of std::array seems not to be as straightforward to initialize with n (undetermined) items as std::array (without explicit initialization). How can this be made possible? Thank you!
std::arraymust be known at compile time. That's why the size is templatedint[] foo()doesn't compile, as well asint foo()[].