Boost logo

Boost Users :

Subject: Re: [Boost-users] mpi/serialization: broadcasting derivedclass through base pointer
From: Robert Ramey (ramey_at_[hidden])
Date: 2012-01-20 12:05:09

MM wrote:
>> -----Original Message-----
> Hello Matthias, Robert Ramey,
> I am revisiting the topic of mpi broadcast-receiving a polymorphic
> object through a base class null pointer:
> void recv_histodata(boost::mpi::communicator& world)
> {
> historical_data_base* hd = nullptr;
> boost::mpi::broadcast(world, hd, master_process);
> }
> historical_data_base has 3 derived classes.
> I get the unregistered class exception from the serialization
> library, and so I am trying to register the derived type as shown in
> the serialization doc at /libs/serialization/doc/index.html :
> reference
> ar.template register_type<derived_one>();
> but where do I put that?

invoke that any time after the archive is created but before the
"derived_one" is serialized.
make sure you do it in the same place on saving an loading. I believe the
following would work.

binary_oarchive oa(...)

oa.template register_type<derived_one>;


binary_iarchive ia(...)
ia.template register_type<derived_one>;

> Regards,
> MM

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at