pure static

bearophile bearophileHUGS at lycos.com
Mon Jan 6 18:45:27 PST 2014


Meta:

> But is it ever legal to return a local stack-allocated static 
> array from a function in D?

It's legal because in D fixed-size arrays are values. So D copies 
them (but in in some cases theory it can allocate them in the 
stack frame of the caller and avoid the copy).


> Won't that entail a copy either way?

In the code I've shown I have used "pure static", so the array is 
allocated statically, not on the stack.

Bye,
bearophile


More information about the Digitalmars-d mailing list