Re: Re: [boost] Re: [serialization] pointers to built-in types

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

On Sun, 9 May 2004 11:08:53 -0700, Robert Ramey wrote
Dave Harris wrote: 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.
Seems like there is another solution as well. The user writing the serialization code can write the code to dereference the pointer when writing and to construct new storage on reading. Yes, it's a bit different than the usual serializaiton code, but then a class that has a pointer like this is a bit unusual and if it is the unusual case, won't be a big problem. Jeff
participants (2)
-
Jeff Garland
-
Robert Ramey