Allocating a slice object

Marco Leise Marco.Leise at gmx.de
Mon Jul 8 08:43:35 PDT 2013


Am Thu, 04 Jul 2013 15:54:48 +0200
schrieb "monarch_dodra" <monarchdodra at gmail.com>:

> > This should work:
> >
> > int[] *pSlice = (new int[][1]).ptr;
> >
> > -Steve
> 
> Hum... That would allocate a dynamic array of slices though 
> right? There'd be the Appendable overhead for just one element...

No, it allocates a static one-element array of int[]s and then
returns the pointer to the first and only element. It's
similar to wrapping it in a struct. So +1 for that solution.

-- 
Marco



More information about the Digitalmars-d-learn mailing list