Allocating a fixed-size array on the heap

Janice Caron caron800 at googlemail.com
Thu Jan 31 00:00:22 PST 2008


On Jan 30, 2008 2:45 PM, Jarrett Billingsley <kb3ctd2 at yahoo.com> wrote:
> So, in the process of answering another thread, I realized that it doesn't
> entirely seem possible to allocate a fixed-size array on the heap through
> normal means.  That is,  the following is legal:
>
> float[4] a;
> float[4]* b = &a;
>
> But:
>
> float[4]* c = new float[4];

I guess you could always do

    struct FixedSizeArray(T,uint N) { T[N] array; }
    float[4]* c = &(new FixedSizeArray!(float,4)()).array;

?



More information about the Digitalmars-d mailing list