2 ms·
It's not just the random initialization order that didn't make it from C99 into C++, other features also don't work, most notably: ...no chaining of designated
by flohofwoe 3y ago
It's not just the random initialization order that didn't make it from C99 into C++, other features also don't work, most notably:
...no chaining of designated initializers:
const bla_t bla = { .a.b.c = 23 };
...and no array indexing:
const blub_t blub = {
.arr = {
[4] = 23,
[2] = 1
}
};
...all those limitations taken together, and the C++ designated initialization feature is pretty much useless except for the most trivial structs - while in C99, designated initialization really shines with complex, nested structs.
The funny thing is that none of those limitations would be required. Clang had supported full C99 designated init in C++ mode just fine for many years before C++20 appeared.
- calamari4065 3y agoOh man, I've desperately wanted both of these features in basically every language I've used. I think you can do a similar sort of array initialization in C#, but definitely not chained initializers. Those are both so useful, but I can see why they aren't included in C++/++
- loeg 3y ago> all those limitations taken together, and the C++ designated initialization feature is pretty much useless except for the most trivial structs We find it pretty useful even with the limitations. Certainly not “pretty much useless.”