Does x.resize(1024)
guarantee that a valarray
x
will be zeroed?
Does std::valarray<float> z(1024);
guarantee that it will be filled with zeros as well?
Is this true for Mac, Windows, Linux? Is this true even for C++03 (I'm not using C++11)?
(All documentation that I've read seems to prove it true, but 1) the docs don't explicitely state what happens if 2nd parameter is omitted 2) I'm trying to debug an exotic bug, that is hard to reproduce, in which some arrays are not zeroed by default, I'm unable for now to post a minimal code showing this bug, but I'll try to add one once available)
Example code:
#include <valarray>
#include <complex>
int main()
{
std::valarray<double> x;
std::valarray<std::complex<double>> y;
std::valarray<float> z(1024);
x.resize(1024);
y.resize(1024);
// are all x, y, z filled with zeros?
}