Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-07-06 16:48:51

I suspect you didn't include <boost/serialization/shared_ptr.hpp> which
includes serialization code for shared_ptr. It also includes shared_ptr.hpp
itself. This is similar to the way the headers are organized for all the
stl collections. If you want to serialize the boost share_ptr be sure to
read about in the docs as there are a few gotchas. Also note that there the
"real soon to be released" boost 1.33 has a different shared_ptr and
different serialization of the same.

Good Luck.

Robert Ramey

boost_at_[hidden] wrote:
> I was using my own home-grown one. I wrote it before I started using
> boost though. I decided to try it out with boost::shared_ptr and
> here is what I got:
> c:\Boost\boost_1_32_0\boost\serialization\access.hpp(106): error
> C2039: 'serialize' : is not a member of 'boost::shared_ptr<T>'
> I tried searching on boost shared_ptr serialize but came up empty.
> Any suggestions? Thanks.
> ----- Original Message -----
> From: "Robert Ramey" <ramey_at_[hidden]>
> To: boost-users_at_[hidden]
> Date: Tue, 5 Jul 2005 20:18:00 -0700
> Subject: Re: [Boost-users] Serialization and null pointers
>> boost_at_[hidden] wrote:
>>> Thanks. If I changed the order of the members being serialized it
>>> worked fine. Weird.
>>> However, I am running into a problem. I am using reference counted
>>> Smart Pointers. If I serialize the reference counter, then when it
>>> is loaded it will likely contain too large of a reference count
>>> because there were more objects referencing the pointer when it was
>>> saved than when it was loaded. However, it works fine it just
>>> doesn't properly delete the objects because the reference count
>>> never reaches 0.
>>> If I don't serialize the reference count then the objects try to
>>> delete themselves while boost is loading them from the file. I'm
>>> guessing because of the order everything happens, the final
>>> destination isn't increasing the reference count until after boost
>>> already dereferences it.
>>> Any suggestions?
>> I'm not sure which reference counted Smart Pointer you're using. If
>> you use the boost smart_ptr, its already has serializaiton done. If
>> you want to add serialization to your own Smart Pointer, you can
>> look at how it was done for the boost smart pointer - now there are
>> two versions so you have lots of ideas available.
>> Robert Ramey
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at