On Saturday, 21 September 2013 at 10:40:07 UTC, bearophile wrote:
simendsjo:
This is incorrect, but what is the correct syntax? The arrays
page only says it's "an advanced feature", but doesn't show
the syntax.
int[] a = new int[1](void);
The simplest way to allocate a void-initialized GC-managed
dynamic array in D is probably to use one of the two functions
designed for such purpose inside std.array. I suggest to use
minimallyInitializedArray and to avoid uninitializedArray
unless you have very special needs. minimallyInitializedArray
is GC-safer.
auto a = minimallyInitializedArray!(int[])(1);
If you don't want a dynamic array, but a static one, then the
simplest solution is to wrap it with a static struct and
allocate it using a GC.malloc...
Bye,
bearophile
Thanks. uninitializedArray works well for my need.