How can I allocate a int[] array on stack?
Daniel Kozak
kozzi11 at gmail.com
Fri Mar 26 06:45:39 UTC 2021
On Fri, Mar 26, 2021 at 7:36 AM Daniel Kozak <kozzi11 at gmail.com> wrote:
> On Fri, Mar 26, 2021 at 7:31 AM Daniel Kozak <kozzi11 at gmail.com> wrote:
>
>> On Fri, Mar 26, 2021 at 6:50 AM Jack via Digitalmars-d-learn <
>> digitalmars-d-learn at puremagic.com> wrote:
>>
>>> What's the equivalent of C's VLA in D? scoped from std.typecons
>>> doesn't seem to work with arrays. Should I use alloca() for my
>>> array or is there something else?
>>>
>>
>> https://dlang.org/library/std/array/static_array.html
>>
> Sorry I was misread this
>
You can use allocator:
import std.experimental.allocator.showcase;
import std.experimental.allocator;
import std.stdio;
StackFront!4096 stackAlloc;
void main() {
int[] a = stackAlloc.makeArray!int(2);
writeln(a);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20210326/489cdaf1/attachment-0001.htm>
More information about the Digitalmars-d-learn
mailing list