M
Marcin Kalicinski
int a; // #1 uninitialized value
int a(0) // #2 zero-initialized value
std::vector<int> v(10); // #3 zero-initialized values (why?)
std::vector<int> v(10, 0); // #4 zero-initialized values
How do I construct a vector of ints without initializing them to zero? Why
is #3 zero-initializing the ints? This is unintutitive, unexpected and slow.
If one wanted to intialize he would use syntax #4.
World would be better if int() created uninitialized value.
cheers,
Marcin
int a(0) // #2 zero-initialized value
std::vector<int> v(10); // #3 zero-initialized values (why?)
std::vector<int> v(10, 0); // #4 zero-initialized values
How do I construct a vector of ints without initializing them to zero? Why
is #3 zero-initializing the ints? This is unintutitive, unexpected and slow.
If one wanted to intialize he would use syntax #4.
World would be better if int() created uninitialized value.
cheers,
Marcin