|
Boost Users : |
Subject: Re: [Boost-users] [serialization] std::shared_ptr with Boost >= 1.53
From: Robert Ramey (ramey_at_[hidden])
Date: 2015-05-04 16:25:54
beet-2 wrote
> Robert,
>
> there seems to be a misunderstanding here, and I apoligize for not
> having been more clear before. Here is the history again:
>
> - I have converted a client-server application from using
> boost::shared_ptr to std::shared_ptr
>
> - The server now needs to serialize a ** std::shared_ptr ** and the
> client wants to receive a ** std::shared_ptr **
>
> - No boost::shared_ptr is involved anymore, and the problem is NOT the
> conversion from a boost::shared_ptr - based archive to a std::shared_ptr
> archive
>
> - Serialization of std::shared_ptr works with Boost 1.58, but isn't
> supported by Boost 1.53
>
> - I need to make it work with older versions of Boost than 1.58, so I
> need to "teach" 1.53 to (de-)serialize a std::shared_ptr
I can't see why you can't just handle use versioning of serializable classes
as described in the manual.
struct myclass {
std::shared_ptr<Sometype> m_x; // used to use boost::shared_ptr<Sometype>
...
template<class Archive>
serialize(Archive & ar, const unsigned int version){
if(version < 1){
boost::shared_ptr t;
ar & t;
m_x = t;
}
else {
ar & m_x;
};
};
BOOST_SERIALIZATION_CLASS_VERSION(myclass, 1);
OK - I see the problem, matching up the matching pointers.
Look at how boost::shared_ptr and std::shared_ptr are implemented
via serialization helper and look at the decimation on serialization
helper.
This might work for you
Robert Ramey
-- View this message in context: http://boost.2283326.n4.nabble.com/serialization-std-shared-ptr-with-Boost-1-53-tp4674950p4675075.html Sent from the Boost - Users mailing list archive at Nabble.com.
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