Re: [Boost-users] serialization: loading std::map replaces existing mapdata objects
Robert Ramey
the copy_collection was an experiment on work has been suspended and probably not be implemented, and if it were implemented, would be implemented differently in anycase.
Ok. Thanks.
b) Just specify a serialize function for the particular map you are using. e.g.
template<class Archive> void serialize(Archive & ar, std::map
> & t, const unsigned int version){ // for each member in the map ar & *it; } I believe that b) would be a good solution for you.
Yes thats ok, but I was serializing more than one map in the same class and I wanted to maintain the separation in xml. I guess I'd have to derive my own map I lazily trying to avoid that.
You post clarifies one point in particular. My version implements the most commonly desired behavior - but not the only behavior people might want. In other words - there is not always agreeement on what it means to "restore" something. And in fact the serialization implementation uses both and some time its confusing.
Yes I agree, though in my case, now I know the limitation, its not difficult to refactor. I do find the refactoring (conditionally initialize after a load) a little forced however. Thanks again for the response. -- Peter Whaite.
Yes thats ok, but I was serializing more than one map in the same class and I wanted to maintain the separation in xml. I guess I'd have to derive my own map I lazily trying to avoid that.
Oh then maybe you want:
void serialize(boost::archive::xml_oarchive & ar, std::map
participants (2)
-
Peter Whaite
-
Robert Ramey