I need to read a large binary file (~1GB) into a std::vector<double>. I'm currently using infile.read to copy the whole thing into a char * buffer (shown below) and I currently plan to convert the whole thing into doubles with reinterpret_cast. surely there must be a way to just put the doubles straight into the vector?
I'm also not sure about the format of the binary file, the data was produced in python so it's probably all floats
ifstream infile(filename, std--ifstream--binary);
infile.seekg(0, infile.end); //N is the total number of doubles
N = infile.tellg();
infile.seekg(0, infile.beg);
char * buffer = new char[N];
infile.read(buffer, N);
std::dequewould suit your requirements.