On Friday, 11 January 2019 at 15:23:08 UTC, Dgame wrote:
On Friday, 11 January 2019 at 14:46:36 UTC, Andrey wrote:
Hi,
In C++ you can create a fixed array on stack:
int count = getCount();
int myarray[count];

Small correction: this is valid in C, but not in C++.

In D the "count" is part of type and must be known at CT but in example it is RT.
How to do such thing in D? Without using of heap.

You could try alloca:

Indeed, but make sure you read up on the caveats of using alloca. I believe all use cases of VLA/alloca have better alternative implementation options.

-Johan

Reply via email to