serialization/fusion: non intrusive serialize() function templated on type being serialized

Hello, I have a base class and a large number of derived classes that are all adapted as fusion sequences. The intention is to serialize through the base pointer. struct Base; struct D_1 : public Base;struct D_2 : public Base;... All the D_i are adapted as fusion sequences. Besides, there is an mpl vector of all the D_i called DVECTOR. In a normal setting, I would have written this: template <typename Archive>void serialize(Archive& ar, Base& b, unsigned int ){ ar & b.member1;} template <typename Archive>void serialize(Archive& ar, D1& d, unsigned int ){ ar & boost::serialization::base_object<Base>(d); ar & d.memberd1;}BOOST_CLASS_EXPORT_KEY(D1) and the same for all D_i. Then I would need BOOST_CLASS_EXPORT_IMPLEMENT for all the D_i as well in the relevant translation units. The base_object part of serialize() is the same for all D_i The D_i specific part of serialize(), I have the ability to generate with fusion meta functions. This leads to a template function with 2 template arguments: template <typename Archive, template Derived>void serialize(Archive& ar, Derived& d, unsigned int ){ ar & boost::serialization::base_object<Base>(d); // fusion code to work on the Derived fusion sequence to generate a " ar & ... " line for each member of Derived} Robert, My question is about the BOOST_CLASS_EXPORT_KEY() and BOOST_CLASS_EXPORT_IMPLEMENT() macros. Am I able to generate all of them from DVECTOR? regards,
participants (1)
-
Hicham Mouline