[Serialization] Many similar looking types

Hello,
I have to serialize some classes that look like this :
struct A
{
vector

Loïc Joly wrote:
LOL - one really has wonder about such a design! Looks like it calls for a template if you ask me.
I don't see how this would be possible. What could be made to work is to make large macro which looks like: #define BXX(bname) \ template<class Archive> \ void serialize(Archive &ar, bname & t, const unsigned int version){ \ ar & base_object<A>(t);\ }\ BOOST_CLASS_EXPORT(bname) and include BXX(B1) in the file which includes struct B1 etc. Of course if you start down this road then you might as well include the whole struct in the macro. Of course once you do that, you might as well make the template template<int N> struct B { Derived<N> * get(int i); }; which is of course is really a macro with type awareness sauce.
If I do not define anything for Bn classes, I get some archive_exception::unregistered_class exception.
As I would expect. Robert Ramey
participants (2)
-
Loïc Joly
-
Robert Ramey