【发布时间】:2020-09-14 07:57:29
【问题描述】:
我已成功序列化我班的两名成员。
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 中为这些变量定义默认值。
但肯定必须有某种版本控制才能解决这种默认情况?有人可以指出我的文档或者更好的示例代码吗?我在官方website 上找不到任何东西。 (但很可能我只是瞎了..)
【问题讨论】:
标签: c++ c++11 serialization versioning cereal