Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-05-09 13:08:53


Dave Harris wrote:

> I'd rather tell the library exactly which ints can be serialised via
> pointers and which not, and the current solution seems a reasonable way of
> doing that. At least, I can't think of a better one.

To me the cental issue is one of side-effects.

I have a header file which implements serialization for pointers to longs -
and it works great.

Now I forget about the implementation of that header - after all, it works
great - and include it in some other header files for some other project.

Now I have a big mess. Whereever it's been included, pointers to ALL longs
are tracked. Whereever its non included, pointer to longs are flagged at
compiler time. Now the behavior of unrelated code is significantly altered
just be the inclusion/exclusion of a seemingly unrelated component. The
alteration effects even the compilation as well as the execution. Its worse
than a global variable in a global namespace.

That's why pointers to primitive types have been made non-serializable by
default.

And there is a very simple solution - use a wrapper to make the long its own
type. Probably the only thing missing is to specify serialization for
strong_typedef.

Robert Ramey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk