I'm trying to figure out how Cereal serialization works, so i read the documentation (which i find a little lacking imo) and tried to reproduce the code they have in there:
#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;
}
I copied the code directly from Cereal's documentation, but i keep getting an error saying:
type 'cereal::BinaryInputArchive' does not provide a call operator
Apparently i wasn't including correctly the libraries, that fixed the problem.