1
cereal, C++ 직렬화 라이브러리로 대형 벡터를 직렬화하고 싶습니다.대형 벡터 벡터 C++ 시리얼 비 직렬화 문제
예외가 + 표준 : to_string (크기) + "읽지 못했습니다"그렇게하려고하면 "입력 스트림로부터 바이트를! 읽기"+ 표준 : to_string (readSize를) 그러나, "슬로우됩니다.
사람은
#include <iostream>
#include <fstream>
#include "include\cereal\cereal.hpp"
#include "include\cereal\archives\binary.hpp"
#include "include\cereal\types\vector.hpp"
#include "include\cereal\types\string.hpp"
void show(std::vector<int> v) {
for (auto i : v)std::cout << i << ",";
std::cout << std::endl;
}
int main(void) {
const std::string file_name = "out.cereal";
{
std::vector<int> src;
// const int STOP = 10; //OK
const int STOP = 1000; // NG
for (int i = 0; i < STOP; i++)src.push_back(i);
std::cout << "src:" << std::endl;
show(src);
std::ofstream ofs(file_name, std::ios::binary);
cereal::BinaryOutputArchive archive(ofs);
archive(src);
}
{
std::vector<int> dst;
std::fstream fs(file_name);
cereal::BinaryInputArchive iarchive(fs);
iarchive(dst);
std::cout << "dst:" << std::endl;
show(dst);
}
#ifdef _MSC_VER
system("pause");
#endif
return 0;
}
의견을 보내 주셔서 감사합니다. 나는이 문제를 해결할 수 있었다. 바이트 순서를 올바르게 알아야합니다. – ric