On Mon, Jan 3, 2022 at 5:09 AM Peter Dimov via Boost
wrote:
https://godbolt.org/z/afcMqMqrK
Very nice, I had similar idea in message with this link:
https://godbolt.org/z/Kzs6xbo5T
but just to double check:
no way to make initialization work with less {} because that is a language
limitation, right? I mean we could add std::initializer_list constructor
but then array is no longer aggregate?
In other words no way to turn this
array a{{
{ { 1, 2, 3 }, { 4, 5, 6 } },
{ { 7, 8, 9 }, { 10, 11, 12 } }
}};
into
array a{
{ 1, 2, 3 }, { 4, 5, 6 },
{ 7, 8, 9 }, { 10, 11, 12 }
};
without breaking aggregate property of array?
This is what I tried:
https://godbolt.org/z/MoPE8W79v
IMAO although this is less friendly for people that want to just initialize
md array with bunch of scalar values I think the syntax with using "last
level array" is nicer...
Obviously I did not think of all the edge cases so my opinion might change
rapidly.
One big problem I noticed is that we loose ability to group the
initialization(you can see the example in godbolt), but here it is inline.
array a223{
{ 1, 2, 3 }, { 4, 5, 6 } ,
{ 7, 8, 9 }, { 10, 11, 12 }
};
// Unfortunately no way to group stuff with {} for more clarity
// array a223_grouped{
// {{ 1, 2, 3 }, { 4, 5, 6 }} ,
// {{ 7, 8, 9 }, { 10, 11, 12 } }
//};