1

I am trying to use the name-value-pairs functionality and the deferred serialization features of Cereal together, but I can't seem to get it to work.

It seems that cereal::defer( CEREAL_NVP( vecOfSharedPtrs ) ) works in the save(Archive& ar) const function, producing correctly-named output, but writing the same in load(Archive& ar) produces a compilation error.

I get the feeling I'm using it wrong, or it's not supported?

whupsilon
  • 11
  • 1

1 Answers1

1

I recently faced the same scenario. I believe you do not need to use cereal::defer in your load function. I have posted a working excerpt below.

  template <class Archive>
  void load(Archive& archive) {
    //deserializes components
    archive(values);
  }

  template <class Archive>
  void save(Archive& archive) const {
    //serializes components
    archive(cereal::defer(CEREAL_NVP(values)));
    archive.serializeDeferments();
  }