Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2007-12-01 12:51:44


Good call - two issues

a) using built-in serialization of collections
b) saving a pointer to a primitive will result in untracked pointers.
The proposed solution below addresses this second consideration.

Robert Ramey

Sohail Somani wrote:
> On Sat, 01 Dec 2007 08:21:47 +0100, Stathis wrote:
>
>> Hi,
>>
>> What is the right way to serialize/deserialize a container of
>> pointers, e.g. std::vector< int* > ? I want to store the values, not
>> the addresses in this case. Should I just flatten my data and store
>> it in a different fashion, then read the flat data and build my
>> objects with a builder?
>
> I think the main reason is that Boost Serialization doesn't track
> pointers to the primitives. So I have a feeling you want to use
> BOOST_STRONG_TYPEDEF (or whatever it is) and use a vector of those
> things.
>
> Then #include <boost/serialization/vector.hpp> and ar & vec_of_ptrs
>
> If I am not mistaken, I think the magic should take over from there.


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