C++11 谷类序列化--版本化

问题描述 投票:0回答:1

我已经成功地将我的类的两个成员序列化。

    archive(
        cereal::make_nvp("width", m_width),
        cereal::make_nvp("height", m_height),
    );

现在,在以后的版本中,我的代码包含了更多的成员,我想把它们也归档。

    archive(
        cereal::make_nvp("width", m_width),
        cereal::make_nvp("height", m_height),
        cereal::make_nvp("lambda0", m_lambda0),
        cereal::make_nvp("phi1", m_phi1)
    );

然而,这就会崩溃,因为新成员不在旧的存档中。据我所知,没有办法为这些变量定义默认值。make_nvp.

但肯定要有某种版本,这样才能解决这种默认情况?谁能给我指点一下这方面的文档,或者最好是一些示例代码?我在官方的 网站. (但很可能是我瞎了眼...)

c++ c++11 serialization versioning cereal
1个回答
0
投票

为了方便以后的参考--这里记录了如何版本。

https:/uscilab.github.iocerealserialization_functions.html#versioning

© www.soinside.com 2019 - 2024. All rights reserved.