I used the boost :: serialization library for a while, and I think it is very good. You just need to create the serialization code as follows:
class X { private: std::string value_; public: template void serialize(Archive &ar, const unsigned int version) { ar & value_; }; }
No need to create de-serialization code (why did they use operator and operator). But if you prefer, you can still use the <and → operators.
It is also possible to write a serialization method for a class without changes (for example: if you need to serialize an object that comes from the library). In this case, you should do something like:
namespace boost { namespace serialization { template void serialize(Archive &ar, X &x const unsigned int version) { ar & x.getValue(); }; }}
source share