Boost logo

Boost Users :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2006-09-15 12:40:02


Hi Volodya

----- Mensaje original -----
De: Vladimir Prus <ghost_at_[hidden]>
Fecha: Viernes, Septiembre 15, 2006 6:19 pm
Asunto: Re: [Boost-users] [serialization] serialization of pointers
toprimitive types?

> Joaquín Mª López Muñoz wrote:
>
> > The following test program:
> >
> > #include <boost/archive/text_oarchive.hpp>
> > #include <sstream>
> >
> > int main()
> > {
> > int x=0;
> > int* const px=&x;
> > std::ostringstream oss;
> > boost::archive::text_oarchive oa(oss);
> > oa<<px;
> >
> > return 0;
> > }
> ....
> > I've checked the same snippet against Boost 1.33.1, CVS HEAD and
> > RC_1_34_0, using other primitive types like std::string, same
> > problem always. Same problem also for the loading counterpart.
> > When the pointed-to type is not primitive, though, everything
> > works fine, regardless of whether the type has intrusive or non
> > intrusive serialization support.
> >
> > I am sure I'm doing something really stupid here, but I've been
> > banging my head against this several hours. Some clue greatly
> > appreciated.
>
> This never worked, I think. The problem is that if you're saving
> pointers,you need to check if you've already saved that pointer,
> so that on loading,
> you don't get two pointers to to ints, as opposed to two pointers
> to a
> single int, as it should be.
>
> This "tracking" requires runtime map, and I believe Robert decided
> thatmaintaining such map for primitive type can be too expensive.
> I'm not sure
> how valid that point it, not how many hidden stones there are in
> enablingprimitive types to be tracked.

I know primitive types are not tracked, but I take that
to mean that multiple pointers to the same object will result
in duplicated copies in the archive, *not* that serializing a
pointer will result in a compile error.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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