Empty array and AA literals

monarch_dodra monarchdodra at gmail.com
Wed Apr 9 09:45:59 PDT 2014


On Wednesday, 9 April 2014 at 09:33:47 UTC, JR wrote:
>>> Does doing it in two steps allocate twice?
>>
>> Nope. That's perfectly valid (and recomended).
>
> You'll have to agree though that, by analogy, it's not unlike 
> separating declaration from instantiation.
>
> [...]
>
> I would not object to a syntax like T[](length), myself.

I *think* there was some miscommunication here:
auto arr = new int[](99);

Is perfectly valid, and the recommended way to do it (provided 
you know how much you want to allocate when constructing).

> My main pet peeve remains array literals being dynamic.

What do you mean? Perhaps you meant you wanted to allocate a 
static array on the heap? EG, "int[99]* p = new ???;"

Otherwise, I don't really understand the statement.


More information about the Digitalmars-d-learn mailing list