Stack-based @nogc dynamic array

Adam D. Ruppe destructionator at gmail.com
Thu May 16 12:45:03 UTC 2019


I think you have overcomplicated something quite simple.

int[4] buffer;
int bufferLength;

buffer[bufferLength++] = item_to_append;
buffer[bufferLength++] = item_to_append;

int[] slice = buffer[0 .. bufferLength];

// you can use slice to any std.algorithm calls etc
// just remember it is on the stack so don't store it beyond a 
function call


More information about the Digitalmars-d-learn mailing list