Rebecca Lehman wrote:
> Does anyone have an example of how to
serialize such pointers?
>
Here are some observations on your
email
a) note that the issues related to pointers and
non-default constructors
or orthogonal so you actually have two separate
problems here.
b) non-default constuctors. Check out files
in the ...../libs/serialization/test directory:
test_non_default_ctor and
test_non_default_ctor2. Make a small program
to test your serialization - don't use pointers
just make sure the
basic serialization works.
c) pointers. The system is designed to permit
serialization through an
abstract pointer to a base class. However, it
does require some care
1) there are two methods - "register" and "export"
- you've used both
in our example. I recommend using one or the other
just to keep
from getting too confused.
2) remember if you serialize through a derived
pointer you can't
de-serialize through the base class. That is,
you always have
to de-serialize to the exact same type you
serialized from.
3) your example shows
class D2 {
...
};
BOOST_CLASS_EXPORT_GUID(D1, "D1"); // should be D2
!!!
check out
...../libs/serialization/test/test_exported.cpp for an example.
Robert Ramey