Templated Interfaces?

Benji Smith dlanguage at benjismith.net
Sun Aug 24 15:39:37 PDT 2008


Jarrett Billingsley wrote:
> Well arrays work _almost_ the same way as in Java, the only difference being 
> that they can change their size.
> 
> You can either do
> 
> auto array = new I!(char)[3];
> array[0] = ..
> array[1] = ..
> array[2] = ..
> 
> Or just declare it and append stuff.  The former will be faster since you'll 
> only do 1 memory allocation instead of n (although the implementation does 
> over-allocate for arrays so that appending is faster, you may not want to 
> depend on that for performance-critical code). 

Huh. I thought that, by putting an integer literal into the array 
declaration, it'd be declared as a static array rather than a dynamic array.

--benji


More information about the Digitalmars-d-learn mailing list