> Hi, > > I tried to do the following: > auto arr = new int[2][2]; > arr[] = 1; // using array expressions > // The above gives - Error: cannot implicitly convert expression (1) of > type int to const(int[2u][]) > > This was the first step to try out if array arithmetic that worked with > single dimensional arrays worked with multi-dimensional. I guess it does > not. > > The immediate utility of this would be to cleanly do matrix algebra. Any > ideas why powerful array expressions were not extended to multi > dimensional arrays as well? > > Regards, > Madhav
It wouldn't really help in this case, but I would point out that you probably didn't declare the type of array that you meant to (you might have, but most people wouldn't really want the type of array that you declared but _would_ mistakenly use the syntax that you used). You declare an int[2u][], whereas what you probably wanted was an int[][]. You have a dynamic array of static arrays where each static array has a fixed length of 2. If you want a dynamic array of dynamic arrays, you need to do this: auto arr = new int[][](2, 2); - Jonathan M Davis
