Creating 1000 instances
Виталий Фадеев
vital.fadeev at gmail.com
Fri Feb 19 08:04:19 UTC 2021
We have:
class File
{
// WIN32_FIND_DATAW data;
}
void fastReadDir()
{
File[] files;
// reserve space, allocating instances
files = new File[]( 1000 ); // <--- trouble here ?
// filling instances
auto file = files.ptr;
writeln( file.data ); // <--- or trouble here ?
// ...
}
Got:
SegFault
Goal:
Allocate memory for 1000 instances at once.
Source:
https://run.dlang.io/is/xfaXcv
Question:
What is the true, fastest, beauty way to create 1000
instances of the class File ?
More information about the Digitalmars-d-learn
mailing list