
B Hart wrote:
I've been having some problems storing and loading a class with a map and a multimap. The map contains values that are simple objects of another class. My questions are below. Here is also a link to the same question posted on stackoverflow. Thanks.
http://stackoverflow.com/questions/1676781/boost-serializing-of-object-conta...
See below a main() and two very simple classes. Then per Boost serialization (and what is shown) my questions are:
1) Does class B need the normal overloaded stream insertion operators '<<' and '>>' to be defined? Currently in my real code it doesn't have these.
As stated in: http://www.boost.org/doc/libs/1_40_0/libs/serialization/doc/tutorial.html#si... you provide a template member function: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) or non-intrusively: http://www.boost.org/doc/libs/1_40_0/libs/serialization/doc/tutorial.html#no... namespace boost { namespace serialization { template<class Archive> void serialize(Archive & ar, gps_B& b, const unsigned int version)
2) Does class A in the store() and load() methods need to iterate through the map and multimap containers explicitly, storing/loading their key:value pairs explicitely? e.g. something like:
I assume that I don't need to do this, but am not certain.
As in:
http://www.boost.org/doc/libs/1_40_0/libs/serialization/doc/tutorial.html#st...
#include
3) Assuming class B has only the two data members shown, does it need a default constructor included explicitly? (as opposed to the implicit default constructor)
Not a serialization issues, but what if you ever default construct a B and use it, what state do you want it in?
4) Does B need to have an overide for the comparison operator '>'? I assume that it doesn't since this is a very simple class.
Not sure what this has to do with serialization. Jeff