Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] polymorphic archives indllsandpointer to derived problems
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-01-04 16:20:27


Kolb, Jeremy wrote:
> Thanks for the help but I don't quite follow:
>
> A) Isn't the point of using the polymorphic types is to avoid
> instantiating all the types explicitly (at the cost of
> performance/virtual function calls)?

assuming we're talking about polymorphic_?archive here.

Now I think about it, I think I gave wrong advice. The correct
thing would be to instantiate polymorphic_iarchive and polymorphic_oarchive
when creating the DLL. which is what I think you did.

BUT you should also make sure these archive types are used by
making the following changes:

>> int _tmain(int argc, _TCHAR* argv[])
>> {
>> std::ofstream f("c:\\test.xml");
         // note creation of derived type of archive asigned to the base
type of archive !!
>> boost::archive::polymorphic_oarchive & xml =
>> boost::archive::polymorphic_xml_oarchive(f);
>>
>> Base* b = new Derived(123);
         // now serialization should proceed through polimorphic_oarchive
interface
>> xml & BOOST_SERIALIZATION_NVP(b);
>>
>> delete b;
>>
>> return 0;
>> }

 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