Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] std::shared_ptr with Boost >= 1.53
From: beet (r.berlich_at_[hidden])
Date: 2015-05-03 16:33:20


Dear Robert,

thanks a lot! Do I understand it correctly, that I could easily create
my own serializer for std::shared_ptr by just (de)serializing the
contained "raw" pointer and wrapping it into a std::shared_ptr in the
case of de-serialization ?

>From what I can see, I do not have to care about the reference counter
inside of the smart pointer. An object that is serialized and
de-serialized somewhere else has a life on its own there. In my case,
the objects are sent back later, but from the time of arrival back in
the home system lead a life of their own.

Best Regards,
Ruediger

Am 30.04.15 um 23:16 schrieb Robert Ramey:
> Rüdiger Berlich wrote
>> Hi there,
>>
>> I need to support various versions of Boost, but am in the process of
>> porting our entire code base to C++11. This involves replacing those
>> constructs of Boost that are now in the standard with their
>> C++11-counterparts.
>>
>> A prime example is std::shared_ptr. However, most of our code needs to be
>> serializable. I know that serialization of std::shared_ptr is possible
>> with Boost 1.58. But 1.53 (the oldest version I need to support) cannot
>> serialize std::shared_ptr .
>>
>> Is there any reason not to include the 1.58-Version of
>>
>> #include <boost/serialization/shared_ptr.hpp>
>>
>> instead of the older version, if I detect a Boost-version < 1.58 ?
>
> I believe that #include &lt;boost/serialization/shared_ptr.hpp&gt; should
> support both boost::shared_ptr as well as std::shared_ptr. Check
> test_shared_ptr. I believe this is illustrated here.
>
> Note that this is an unusual case since boost shared_ptr serialization
> is supported in the serialization library rather than the boost smart_ptr
> library so the above advice is not universally applicable.
>
> Robert Ramey
>
>
>
>
>
> --
> View this message in context: http://boost.2283326.n4.nabble.com/serialization-std-shared-ptr-with-Boost-1-53-tp4674950p4674952.html
> Sent from the Boost - Users mailing list archive at Nabble.com.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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