Create uninitialized dynamic array

Igor Shirkalin mathsoft at inbox.ru
Thu Oct 5 19:59:48 UTC 2017


Hello!

Preface:
I need 1G array of ints (or anything else).

Problem:
I want to quickly fill it with my own data and I do not want to 
waste CPU time to fill it with zeros (or some other value).


I do like this:


void main() {
     int[] data;
     // key code:
     data.length = SOMETHING; // how to create an array and leave 
it uninitialized?

     // fill 'data' with some data
     foreach(i, ref v; data) v=i; // an example
}

Is there a pure way to make what I want?



More information about the Digitalmars-d-learn mailing list