Yes, use std::vector .
So if your code
std:array<int, 42> my_array;
Replace it with
std:vector<int> my_array(42);
Note: you probably do not want to use reserve because it leaves vector empty. If you use std::array , your code does not have the concept of an empty array, so it is best represented by an instance of std::vector , which is populated during construction and never changes.
anatolyg
source share