
On Tuesday, April 17, 2007 at 18:17:22 (-0800) Gennady Khokhorin writes:
I have vector<double> timeStamps; How to store this vector to outside binary file in boost style? I'm trying to utilyze mapped file:
std::vector<double> timeStamps; std::string filePath("c:\\double_test.bin"); boost::intmax_t thisFileSize(maxSize); // max good value: 0x2FFFFFFF ios::filtering_ostream out; ios::file_sink fsink(filePath); out.push(fsink); //out.write(time_stamps.begin(), thisFileSize); // out.flush(); fsink.close();
Use serialization, though not sure a mapped file is what you want:
template<typename Archive>
struct Serializer {
static void save(const vector<double>& timeStamps) {
std::ofstream ofs("file.bin", std::ios::binary);
Archive oa(ofs);
oa << timeStamps;
}
};
Serializer