"The total size of a static array cannot exceed 16Mb."

Janice Caron caron800 at googlemail.com
Tue Oct 2 06:54:47 PDT 2007


On 10/2/07, Vladimir Panteleev <thecybershadow at gmail.com> wrote:
> P.S. I believe your function can be reduced to this without any significant changes in behavior:
>
>      T[][] ret = new T[][x];
>      foreach(ref row;ret)
>          row.length = y;
>
>      return ret;

For that matter, I think you could also do:

    template MultiDimArray(T,int N)
    {
        static if (N == 1)
            typedef T[] MultiDimArray;
        else
            typedef MultiDimArray!(T,N-1)[] MultiDimArray;
    }

    MultiDimArray!(T,N) MakeMultiDimArray(T,int N)(int dim, int[] others...)
    {
        static if (N == 1)
            return new T[dim];
        else
        {
            MultiDimArray!(T,N) t;
            t.length = dim;
            foreach(ref a;t) a =
MakeMultiDimArray!(T,N-1)(others[0],others[1..$]);
            return t;
        }
    }



More information about the Digitalmars-d mailing list