On Thursday, 13 July 2017 at 12:45:19 UTC, Stefan Koch wrote:
[ ... ]

Hi Guys, I managed to hack around the issue of multi-dimensional static array parameters.

making the following code work in newCTFE:

int[] fold (int[4][3] a)
{
  int[] result;
  result.length = 4 * 3;
  int pos;
  foreach (i; 0 .. 3)
  {
    foreach (j; 0 .. 4)
    {
      result[pos++] = a[i][j];
    }
  }
  return result;
}



static assert (fold ([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) ==
              [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);

Enjoy!


Reply via email to