Hello Saaa,

Ever heard of recursion?

Why don't you simply handle all types recursively?

I'm still very interested in what exactly that means. Could you maybe
give a small example?


int Index(T)(T arr, int[] ind)
{
 static if(is(T B == B[][])) // if array of array
     return Index!(B[])(arr[ind[0]], ind[1..$]);
 else
 {
     static assert(is(T B == B[])); // had better be an array;
     return arr[ind[0]];
 }
}

void main()
{
   int[][][] d;
   d.length = 3;
   d[1].length = 3;
   d[1][2].length = 3;
   d[1][2] = [0,1,1];

   assert(0==Index!(int[][][])(d,[1,2,0]));
}


Reply via email to