Boost logo

Boost Users :

Subject: [Boost-users] help on build and write pointer to socket in raw mode
From: boost_at_[hidden]
Date: 2011-04-12 12:57:54

On Mon, 11 Apr 2011 22:06:01 -0700 (PDT), Jerry wrote:
 Thanks Robert.
You mis-understood my intention. What we want is to serilaize an derived
type object directly (not throught base type pointer) but deserialize it to
a base type pointer. So we want the exactly the following codes:   Derived
oa > b;   But it seems this does not work. The reason we prefer this is
that we have three nodes. One node sends/serialize the derived type object,
while two other nodes are receivers. Howerver, one receives/deserializes
the obj via derived type and the other deserializes the obj via base type
pointer. We want,   // The sender Derived d;
oa > b;   // The
other Receiver  Derived dcopy; ia >> dcopy;       On Tue, Apr 12, 2011 at
2:14 PM, Robert Ramey [via Boost] wrote:
 Jerry wrote:
> I know that we
can serialize/deserialize a derived type through a
> base type pointer
(using register_type()). But I cannot serialize a
> derived type and
deserialize it through a base type pointer. It seems
> to me the data type
in serialization and deserialization should be
> extactly the same one.

when you serialize through a derived type, extra information
 about the
derived type isn't saved as it's assumed it will
be deserialized the same

> What I want is,
> Base{...};
> Derived : Base{...};
//Derived d;
 Base *d = new Derived; // use this instead !!

boost::archive::binary_oarchive oa(...);
> oa
> Base *b;
boost::archive::binary_iarchive ia(...);
> ia.register_type();
> ia >> b
 // Deseiralize to a base type pointer
> I have tried this but it does
not work. Is there any way to make this
> work?
> Many thanks!!!

 Boost-users mailing
[hidden email] [1]

 If you reply to this email, your message
will be added to the discussion

 View this message in context: Re:
[Serialization] How to serialize a derived type but deserialize it as a
base type pointer? [4]
 Sent from the Boost - Users mailing list archive
[5] at


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