array construction without heap alloc

0ffh frank at frankhirsch.youknow.what.todo.net
Fri Dec 21 17:00:57 PST 2007


Frank Benoit wrote:
> My problem is, i want to do it without heap allocation. So I can do this:
> 
>   void bar( int a, int b ){
>     int[2] arr;
>     arr[0] = a;
>     arr[1] = b;
>     func( arr );
>   }

I don't know, but I'd guess this would also not allocate heap:

void bar( int a, int b )
{
   int[2] arr=[a,b];
   func( arr );
}

regards, frank


More information about the Digitalmars-d-learn mailing list