Do array literals still always allocate?
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun May 14 04:40:02 PDT 2017
On Sunday, 14 May 2017 at 10:18:40 UTC, ag0aep6g wrote:
> On 05/14/2017 01:57 AM, Nicholas Wilson wrote:
>> 1D arrays it doesn't, 2D or higher it does.
>
> What do you mean? This works just fine as well:
>
> ----
> import std.random;
> import std.stdio;
>
> int[2][2] testfunc(int num) @nogc
> {
> return [[0, 1], [num, 3]];
> }
>
> int main()
> {
> int[2][2] arr = testfunc(uniform(0, 15));
> writeln(arr);
> return 0;
> }
> ----
dynamic array literals is what I meant.
More information about the Digitalmars-d-learn
mailing list