You are including <array> so I guess you want to use std::array instead of a normal array. The size of an std::array has to be known at compile time which is not the case here so std::vector is probably a better choice.