Boost logo

Boost Users :

Subject: [Boost-users] boost::serialization - Non intrusive serialization of user-defined members?
From: Lars Ruoff (lars.ruoff_at_[hidden])
Date: 2018-03-05 13:12:39


Hi,
I have a class structure like

class MemberClass;

class ContainerClass {
  MemberClass special_member;
  int other_members;
};

Following the example in
http://www.boost.org/doc/libs/1_66_0/libs/serialization/doc/
i want to write a non-intrusive serialization:

template<class Archive>
void serialize(Archive & ar, ContainerClass & c, const unsigned int version)
{
  ar & c.other_members; // easy - built-in type
  serialize(ar, c.special_member, version); //use same version???
}

Assuming there's is also a non-intrusive
void serialize(Archive & ar, MemberClass & m, const unsigned int version);

this compiles and works but i feel this is not the way to do it because it
reuses the version number of the container class for the member class? So
how to handle that? Must the Container class manage version of its members
individually?
I suggest to add a section "Non-intrusively Serializable Members" to
documentation with an example.

Cheers,
Lars R.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net