Can I use something like std::array<int[2][2], 2>
as a substitute for int[2][2][2]
, just like std::array<int, 2>
can be used instead of int[2]
?
What I really need is maybe a statically-sized multidimensional array that
- Have "proper" value semantics, and
- Is stored contiguously in memory.
It seems that, unlike C-style arrays, std::array
of std::array
is not guaranteed to have fully compactified memory, as std::array
may contain padding.
What are possible issues I might have if I use something like std::array<int[2][2], 2>
? Perhaps this is a too vague question, but it's hard to figure out why exactly I'm not comfortable and somewhat doubtful using it for my purpose.