On Monday, 21 October 2013 22:35:43 UTC+3,
bobl...@gmail.com wrote:
> Correct me if I am wrong, but there seems to be a least 2 short comings (at least to my view point) to using std::array :
>
> 1) no equivalent to
> int myArray[] = { a very long list of values too long to conveniently count };
Correct. That is the sole shortcoming and such long arrays are rare and
usually immutable.
> 2) no equivalent to
>
> void func (int[], int[][3] );
Wrong. That declaration is /exactly/ equivalent to:
void func (int*, int(*)[3]);
No arrays are passed there, just pointers. 'std::array' can be converted
to pointer to underlying array with 'data()' but why? Just pass pointer
to 'std::array'.
> in other words, when converted to an std::array we need to specify the
> size of all of the dimensions of arrays passed to a function.
If the function does not know the dimensions then how can it dare to
touch the elements of array? Unsafe "hopefully it is OK"? That is common
source of errors. If it does know it then what is the problem to
indicate it in interface? If it should accept different arrays then
it can be made a template and if the arrays are made dynamically
then it is 'std::vector' (not 'std::array') that you need instead
anyway.