January 11, 2018 Re: new int[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Luís Marques | On Wednesday, 10 January 2018 at 23:08:28 UTC, Luís Marques wrote:
>> void main()
>> {
>> int[]* x = &[[1, 2, 3]][0];
>> int[]* x2 = [[1, 2, 3]].ptr; /* same */
>> }
> That's an interesting solution. I'm not sure which one I prefer, the wrapper or this one. Still... I feel like the language should just allow allocating an array itself on the GC heap :(
I believe this does allocate from the automanaged heap already. At least it won't work with @nogc. If one wants to reserve the memory from the program space, he needs to use module-level static arrays. With immutable stuff I don't know, perhaps it's implementation dependant.
|
Copyright © 1999-2021 by the D Language Foundation