Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] Different behaviors between archive and its polymorphic variant
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-08-18 14:33:18


>> So now 'unit' only has a template serialize method, but I still
>>
>>> int main()
>>> {
>>> unit u(42);
>>>
>>> {
>>> std::cout << "template:" << std::endl;
>>> test_oarchive ar(std::cout);
>>> ar << BOOST_SERIALIZATION_NVP(u);
>>> std::cout << std::endl;
>>> }
>>>
>>> {
>>> std::cout << "polymorphic:" << std::endl;
>>> polymorphic_test_oarchive ar(std::cout);
>>> ar << BOOST_SERIALIZATION_NVP(u);
>>> std::cout << std::endl;
>>> }
>>> }
>>
>> Which outputs:
>>
>>> template:
>>> <name=u><name=id_>42</name=id_>
>>> </name=u>
>>>
>>> polymorphic:
>>> 42
>>
>> Code is attached.

what happens when you try:

std::cout << "polymorphic:" << std::endl;
polymorphic_oarchive & po = polymorphic_test_oarchive ar(std::cout);
po << BOOST_SERIALIZATION_NVP(u);
std::cout << std::endl;

This would actually be using the polymorphic interface as it's
intended to be used by routing the serialization through the polymorphic
interface.

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