3 ms·
Oh how I agree about the uniform initialization! And to make matter worse, I now work on a code base where it is the mandated form in the coding standard. At le
by pierrebai 5y ago
Oh how I agree about the uniform initialization! And to make matter worse, I now work on a code base where it is the mandated form in the coding standard. At least your initial example now gives me ammunition against it, but too late for this coding standard.
It makes code look silly, too, as now initialization looks different from assignment.
int i { a + 2 };
i = a + 4;
int j = a + 2;
j = a + 4; // ah! consistency!
- ncmncm 5y agoIt is good for initialization to look different. It is different. Not so much so for int, but maybe hugely different for other types.
- pjmlp 5y agoTo build up on sibling's answer that isn't the same thing. The first one will call the initialization constructor, whereas the second form will initialize the object and then apply one form of copy construction, depending on which ones are available (user provided or compiler generated). It just happens that for int that doesn't matter in practice.