Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2004-12-01 16:54:17

----- Mensaje original -----
De: Robert Ramey <ramey_at_[hidden]>
Fecha: Miércoles, Diciembre 1, 2004 10:15 pm
Asunto: [boost] Re: Re: [multi_index] announce: serialization support

> If you guarentee that the container itself is always serialized
> before your
> indices, then de-serialization of the indices would automatically
> be reduced
> to providing the original (tracked) pointer. In such a case, I
> would think
> the whole isse would never appear and that the implementation
> would be very
> straight forward.

I think this is not correct (but I'd like to be
proven wrong, that'd mean I could simplify my code.)
Consider this:

struct foo
  std::list<std::string> cont;
  std::string* pos; // pos points to an element of cont

  friend class boost::serialization::access;

  template<class Archive>
  void serialize(Archive & ar, const unsigned int)
    ar&cont; // before pos, as you suggest

My thesis is that loading a foo will get it
wrong --pos won't be pointing to an element of cont,
but rather to some random address in stack memory.
I'll check it out on my compiler tomorrow, but I was
already through this when designing multi_index
serialization. See my point now? Am I missing something?

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

Boost list run by bdawes at, gregod at, cpdaniel at, john at