[Serialization] Registering containers of user-provided types

I am writing a library that will handle storing and serializing user-defined
types. The user-defined types are required to be themselves serializable.
However the library uses templates to create containers of user types. These
containers are then serialized through a base class pointer. I don't know
how to export the container types to boost::serialization through the
templates. The only way I can do it is to force the user of the library to
BOOST_CLASS_EXPORT_GUID() every container type.
I've tried unpacking the macro by looking at boost/serialization/export.hpp,
but it is slightly complex... Is there a way to export a class as part of
the template instantiation? Or another way to write the library to easily
serialize containers of user-defined types?
Thanks
-v
Example code:
#include <iostream>
#include <vector>
#include

Vivek wrote:
I am writing a library that will handle storing and serializing user-defined types. The user-defined types are required to be themselves serializable.
However the library uses templates to create containers of user types.
So far so good - look at the serialization implementions for std::vector<T> and others.
These containers are then serialized through a base class pointer. I don't know how to export the container types to boost::serialization through the templates. The only way I can do it is to force the user of the library to BOOST_CLASS_EXPORT_GUID() every container type.
That would be the way to do it. However, someone proposed a solution to this problem and uploaded it as a track item. I found it intriguing, But I decided not to implement it to keep the library from getting any more complicated than it already is. You might want to paste this proposed enhancement into your own code.
I've tried unpacking the macro by looking at boost/serialization/export.hpp, but it is slightly complex.
lol - this is an understatement
Is there a way to export a class as part of the template instantiation? Or another way to write the library to easily serialize containers of user-defined types?
The rub here is your requirement that it be exported through a base class pointer. Were it not for this, it is easily done just like standard containers are. Robert Ramey
participants (2)
-
Robert Ramey
-
Vivek