initializing a static array

Adam D. Ruppe destructionator at gmail.com
Tue Oct 10 14:47:08 UTC 2017


On Tuesday, 10 October 2017 at 14:42:15 UTC, Daniel Kozak wrote:
> It will return dynamic array. it is same as:
>
> double[5] = [0,0,0,0,0]; // this is still dynamicaly allocated.

Not true here, the compiler knows it is going into a static array 
and puts the result directly in there. It handles literals.

The range version though will allocate since the function doesn't 
know where its result ends up. It will CTFE though if the 
variable is static.


More information about the Digitalmars-d-learn mailing list