I wonder whether an n-dimensional array is guaranteed to be contiguous in memory or if it can have "holes" due to alignment and padding. I'm interested especially in structures that do not align to pointer sizes.
I am aware that semantically an uint8_t array[5][7];
is not identical to a uint8_t array[35]
, because the former is 2-dimensional and the latter is 1-dimensional (linear).
I also know that for Bitmaps pixel graphics (2D) one has to consider the stride, but that might be related to compression algorithms, not alignment requirements.
I found a similar question for C, but I'm asking for C++.
Does the standard guarantee that all elements of an n-dimensional array are contiguous? I'm looking for a quote from the C++ standard (draft versions welcome).