• Create Account

### #ActualTrienco

Posted 06 October 2012 - 02:47 AM

Why is this being voted down? His gripe about the initialiser list order not being the actual initialisation order is perfectly valid. It's intuitive to assume that the variables are going to be initialised in the order that the initialisation code is written - which is exactly the case whenever you initialise something using the equals sign.

The only time the equals sign has anything to do with initialization is if it is done at the same time as the declaration. So it is still the declaration order that matters. Or to point it out very clearly
int x;
x = 10; //This is NOT initialization

int x = 10; //THIS is initialization... also technically a special case syntax for "int x(10);"


Also mentioned in this topic, ordering your members for alignment or caching reasons can potentially break your code if one member was initialised using the value of another.

Which would seem like a very good reason not to do that, instead of saying "I'll simply not do proper initialization, so I can make something work, that shouldn't be done in the first place." How many times do you have a situation, where it's not just as easy to initialize both members by the same parameter/default value? And if one value is calculated from the other, how likely is it that one of those isn't redundant and it is vital for your performance to precalculate them both?

### #1Trienco

Posted 06 October 2012 - 02:44 AM

Why is this being voted down? His gripe about the initialiser list order not being the actual initialisation order is perfectly valid. It's intuitive to assume that the variables are going to be initialised in the order that the initialisation code is written - which is exactly the case whenever you initialise something using the equals sign.

The only time the equals sign has anything to do with initialization is if it is done at the same time as the declaration. So it is still the declaration order that matters. Or to point it out very clearly
int x;
x = 10; //This is NOT initialization

int x = 10; //THIS is initialization... also technically a special case syntax for "int x(10);"


Also mentioned in this topic, ordering your members for alignment or caching reasons can potentially break your code if one member was initialised using the value of another.

Which would seem like a very good reason not to do that, instead of saying "I'll simply not do proper initialization, so I can make something work, that I shouldn't be doing in the first place."

PARTNERS