Boost logo

Boost Users :

Subject: Re: [Boost-users] BoostSerialization callinga customserialize method
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-08-27 16:39:35


Pooyan Dadvand wrote:

> Can you please explain me more the idea of extradata structure?
> Consider that my extradata can be a double, ublas::vector, or even
> std::vector<weak_ptr<Element> > or any new type of variables. I
> have:
>
> std::vector<std::pair<VariableData, extradata> > mData
> ...
> ar << mData;
>
>
> and each element of vector can have a different type of data with
> different size or even have pointers. (It's a heterogeneous
> container)

The above will work as written.

Maybe what you want is:

template<class T>
class mytype : std::vector<std::pair<VariableData, T> > {
    template<class Archive>
    void serialize(Archive &ar, const unsigned int version){
        ar << boost::serialization::base_object(*this);
    }
};

then you can

mytype<double> m_t
...
ar << m_t

The possibilities are endless. This really isn't about the serialization
library
but about C++

Robert Ramey


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