Is there a way to zero init an array of any type with a variable size? So what I want is to apply something like this:
int results[5] = {};
to a template like this:
T results[i] = {};
When I try this, my compiler says this: 'results' declared as array of functions of type 'T ()'.
When I use any fixed typename I get this error: Variable-sized object may not be initialized
Also i is a variable that is passed in when this function is called.
std::vector<T> results(i);T results[i];without any problem...-pedanticto your compiler options.T results[i]is a run time sized array and those are not allowed in C++. clang and gcc by default have an extension that lets you do it, but it is non-standard behavior. By using-pedanticyou turn that feature off and tell the compiler to strictly follow the C++ standard.