Boost logo

Boost Users :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2006-09-16 12:06:38


Hello Robert,

----- Mensaje original -----
De: Robert Ramey <ramey_at_[hidden]>
Fecha: Sábado, Septiembre 16, 2006 8:01 am
Asunto: Re: [Boost-users] [serialization] serialization of pointers
to primitive types?

> Serialization of pointers to primitive data types is prohibited.
> I'm pretty sure this is mentioned in the documentation. ( don't
> have the exact reference handy)

I've persued the docs and in every place where this is referred
to, the statement is that primitive types are not tracked, which
is IMHO different than serialization of pointers to primitive
types being forbidden. Examples:

- Serializable concept:

  "A type T is Serializable if and only if one of the following
  is true:
  * it is a primitive type.
  [...]
  * it is a pointer to a Serializable type.[...]"

from which it can be deduced that a pointer to a primitive type
is serializable.

- Object tracking:

  "Default tracking traits are:
  * For primitive, track_never.[...]"

At the risk of repeating myself, I understand what serializing
a pointer to a non-tracked type involves. This is not the same
as not being able to serialize the pointer in the first place,
which is what happens with primitive types, to my dismay.

> - and it has been noted a couple of times. The reason is that
> doing this would result in ALL usages of that type being tracked
> - which is probably a heck of a lot more than the user had in mind.

I'm not talking about primitive types being tracked, which
I agree with you implies an unacceptable burden, but about
the mere possibility of serialization of a pointer to
a primitive type. Wouldn't it be an option that pointers to
primitive types will be handled as non-tracked? What would be
the overhead of that option? In case this is an option, please
consider my vote for inclusion as a new feature in Boost 1.35.

>
> The way to serialize pointer to primitives
> (serialization_level::prmitive) is to use BOOST_STRONG_TYPEDEF to
> define a new type and specify serialization function for it. This
> won't work for std::string so you'll have to make a trivial
> derivation of std::string if you want to serialize a pointer to a
> std::string.

The problem with that is that it is an intrusive solution that
complicates things when dealing with generic code. Sometimes,
it can be just impossible to do that intrusive change or require
the user to do it. From this restriction, for instance, we have
that

  std::set<int*>

is not serializable as is. Telling the user to change her
definition to something like

  std::set<BOOST_STRONG_TYPEDEF(...)*>

just for the sake of serializability could be unacceptable in
some (many?) situations.

> Robert Ramey

Thank you,

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