我试图弄清楚Cereal序列化是如何工作的,所以我阅读了文档(我发现它有点缺乏imo),并试图重现它们在那里的代码:
#include <sstream>
#include <archives/binary.hpp>
struct MyData
{
int x, y, z;
// This method lets cereal know which data members to serialize
template<class Archive>
void serialize(Archive & archive)
{
archive( x, y, z ); // serialize things by passing them to the archive
}
};
int main()
{
std::stringstream ss; // any stream can be used
{
cereal::BinaryOutputArchive oarchive(ss); // Create an output archive
MyData m1, m2, m3;
oarchive(m1, m2, m3); // Write the data to the archive
} // archive goes out of scope, ensuring all contents are flushed
{
cereal::BinaryInputArchive iarchive(ss); // Create an input archive
MyData m1, m2, m3;
iarchive(m1, m2, m3); // Read the data from the archive
}
return 0;
}
我直接从Cereal的文档中复制了代码,但是我不断收到错误消息:
type 'cereal::BinaryInputArchive' does not provide a call operator
答案 0 :(得分:0)
显然,我没有正确包含库,从而解决了该问题。