Allocate N elements

bearophile bearophileHUGS at lycos.com
Mon Jul 15 08:07:47 PDT 2013


Namespace:

> Is it possible to prohibit that the slice is resized, to avoid 
> GC allocations?

For that I think you need to define a struct that disables the 
append and uses an alias this. But then some of your array 
function argument signatures need to change, because lot of D 
code uses "raw" arrays signatures like:

void foo(int[] arg) {}

Instead of:

alias MArr = int[];
void foo(MArr arg) {}

Or using Typedef (untested):

alias MArr = Typedef!(int[]);
void foo(MArr arg) {}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list