CTFE Status 2

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 27 15:48:13 PST 2017


On Thursday, 16 February 2017 at 21:05:51 UTC, Stefan Koch wrote:
> [...]

Simple ref calls work now.
Meaning the following code will compile :)

uint sum(uint[] arr)
{
   uint sum;
   foreach(uint i;0 .. cast(uint)arr.length)
   {
     addToSum(sum, arr[i]);
   }
   return sum;
}
void addToSum(ref uint sum, uint element)
{
   sum = sum + element; // works now as well
   return ;
}

static assert([1,2,3,4,5].sum == 15);


More information about the Digitalmars-d mailing list