如何使用cerial序列化

How to use cerial serialization

我试图弄清楚 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

显然我没有正确包含解决问题的库。