Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-12-08 21:39:54


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.

There is no reason you have to use the default serialization implementation
that I have provided. Your are totally free to make your own and use
that instead. There are a couple of ways to do this.

a) Just don't included boost/serialization/map.hpp. Make your
own version and use it instead. This is probably not real appealing
as it would replace the implementation for ALL the maps.

b) Just specify a serialize function for the particular map you are using.
e.g.

template<class Archive>
void serialize(Archive & ar, std::map<my_class> > & t, const unsigned int
version){
    // for each member in the map
         ar & *it;
}

I believe that b) would be a good solution for you.

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.

binary_object presumes the object is already allocated.

collections assume they are not.

etc.

This has been a source of confusion from time to time. It just turns
out that the desired and/or natural and/or expected behavior seems
to vary depending on the context and the data type.

Robert Ramey

Peter Whaite wrote:
> I was kinda hoping I could construct a std::map with default data
> objects, then use serialization to overwrite some of the their member
> variables. Unfortunately serialization completely replaces the map's
> data objects. I see in 'collections_load_imp.hpp' what I presume is
> code to do what I want but it is commented out:
>
> template<class Archive, class Container, class InputFunction, class R>
> inline void load_collection(Archive & ar, Container &s){
> // if(0 != (ar.get_flags() & boost::archive::no_object_creation))
> // copy_collection<Archive, Container>(ar, s);
> // else
> rebuild_collection<Archive, Container, InputFunction, R>(ar, s);
>
> Is there any chance that copy_collection will work one day, or has it
> been abandoned?
>
> ---
> Peter Whaite.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net