|
Boost : |
From: Ivan Matek (libbooze_at_[hidden])
Date: 2022-01-03 10:43:54
On Mon, Jan 3, 2022 at 5:09 AM Peter Dimov via Boost <boost_at_[hidden]>
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<int, 2, 2, 3> a{{
{ { 1, 2, 3 }, { 4, 5, 6 } },
{ { 7, 8, 9 }, { 10, 11, 12 } }
}};
into
array<int, 2, 2, 3> 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<int, 2, 2, 3> a223{
{ 1, 2, 3 }, { 4, 5, 6 } ,
{ 7, 8, 9 }, { 10, 11, 12 }
};
// Unfortunately no way to group stuff with {} for more clarity
// array<int, 2, 2, 3> a223_grouped{
// {{ 1, 2, 3 }, { 4, 5, 6 }} ,
// {{ 7, 8, 9 }, { 10, 11, 12 } }
//};
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk