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

Lirong wrote:
I remember that pointers to built-in types can not be serialized directly in earlier versions of the library. The user would have to write a wrapper around the built-in type. How is the situation now?
The default serialization traits are such that pointers to primitive types are set to not-serializable. Suppose you set the implementation_level<long> to object serializable and serialize a pointer to a long. This well mean that all serialized longs have to be tracked. Do you want something like this to happen? Its possible to serialize a pointer to primitive - I just can't imagine a case where one would want to do because of the side effects it would cause. That's why I recommend wrapping the primitive in its own type so that you don't create a lot of unexpected/undesired side-effects. Look at strong typedef for a simple cheap automatic wrapper. Robert Ramey

Robert Ramey wrote:
This well mean that all serialized longs have to be tracked.
I think the lib should only track it when it is serialized through pointer. And most of the time, primitives are not serialized through pointers. So there should be any overhead. Best regards, Lirong
participants (2)
-
Li Lirong
-
Robert Ramey