I have a huge x continuous array that I fread from a file.
How to dump this piece in std::vector<> ? In other words, I prefer the result to be in std::vector<> rather than in an array, but I want the resulting C ++ code to be as efficient as this simple C version, which throws a piece directly into an array.
From the search around, I think I may have to use a new placement in one form or another, but I'm not sure about the sequence of calls and problems with ownership. Also, do I need to worry about alignment problems?
I am testing with T = unsigned , but I expect a reasonable solution to work for any POD structure.
using T = unsigned; FILE* fp = fopen( outfile.c_str(), "r" ); T* x = new T[big_n]; fread( x, sizeof(T), big_n, fp );
kfmfe04
source share