On Thursday, 8 December 2016 at 01:52:13 UTC, Stefan Koch wrote:

Array-literals with ctfe-known Variables in them are now supported;
uint[] fn(uint n)
{
  return [n, n, n];
}

static assert(fn(3).length == 3);
static assert(fn(3)[0] == 3);
static assert(fn(3)[1] == 3);
static assert(fn(3)[2] == 3);

This works as well with interspersed constant.
uint[] itrspary(uint n)
{
  return [1, n, 3];
}

static assert(itrspary(7).length == 3);
static assert(itrspary(7)[0] == 1);
static assert(itrspary(7)[1] == 7);
static assert(itrspary(7)[2] == 3);

Reply via email to