Shortest way to allocate an array and initialize it with a specific value.
weaselcat via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 11 05:19:22 PDT 2015
On Thursday, 11 June 2015 at 07:57:47 UTC, Per Nordlöw wrote:
> On Wednesday, 10 June 2015 at 22:03:52 UTC, Ali Çehreli wrote:
>> Another option:
>>
>> void main()
>> {
>> auto a2 = new ubyte[5];
>
> But this causes an extra zero-initialization of a2.
just an fyi, gdc optimizes this away(looks like it overwrites the
typeinfo,) ldc does not.
More information about the Digitalmars-d-learn
mailing list