Boost logo

Boost Users :

Subject: [Boost-users] How to serialize class derived from standard container?
From: Terdale, Shantibhushan (STerdale_at_[hidden])
Date: 2008-10-14 14:57:48


This could be very stupid question but I am stuck with this situation. I
have class A derived from List<B> and B derived from C. How do I write
Serialize method for A? See below, both options I tried are not working.
 
Any help is appreciated. Thanks.
 
class B : public C
{
 private:

    friend class boost::serialization::access;

    template<class Archive>

    void serialize(Archive & ar, const unsigned int version)

    {

        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(C);

    }

};
 
class A : public list<B>

{

public:

       void Append( const list<string>& rBList );

        A::const_iterator FindSpecialB(const B& rB);

private:

        friend class boost::serialization::access;

        template<class Archive>

        void serialize(Archive & ar, const unsigned int version)

        {

                ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(List<B>);

                OR

                ar & boost::serialization::make_nvp("AddressList",
boost::serialization::base_object<list<B>>(*this));

                OR

                ??

        }

};



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