I have a constructor that looks like
A (const int(&inArr)[4])
{
...
}
And I can construct an instance with list-initialization as such,
A a({3,4,5,6});
However, I can also construct an instance with a shorter list, e.g. {3,2}
, or an empty list {}
. From my testing in MSVC and Clang, the array received by the constructor is always zeroed after the values in the list. i.e. {3,2}
will be read as [3,2,0,0]
, and {}
as [0,0,0,0]
.
I am wondering if this is standard behaviour that can be relied upon, or if this may vary across platforms/compilers?