initializing a static array

Daniel Kozak kozzi11 at gmail.com
Tue Oct 10 14:54:00 UTC 2017


Yeah, you are right. My fault.

On Tue, Oct 10, 2017 at 4:47 PM, Adam D. Ruppe via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20171010/ee23e4af/attachment.html>


More information about the Digitalmars-d-learn mailing list