Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9567: De-serialization of enable_shared_from_this through base class pointer fails
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-04 01:16:38
#9567: De-serialization of enable_shared_from_this through base class pointer
fails
-------------------------+-------------------------------------------------
Reporter: Tim Regan | Owner: ramey
Type: Bugs | Status: new
Milestone: To Be | Component: serialization
Determined | Severity: Problem
Version: Boost | Keywords: serialization
1.53.0 | enable_shared_from_this shared_ptr weak_ptr
Resolution: |
-------------------------+-------------------------------------------------
Comment (by ramey):
I compiled and ran your example on my machine and have reproduced the
problem.
Looking at your example, it seems to me that the serialization function of
Derived should be:
{{{
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
ar & boost::serialization::make_nvp(
enable_shared_from_this,
boost::serialization::base_object<boost::enable_shared_from_this<Derived>
>(*this)
)
ar & BOOST_SERIALIZATION_NVP(m_derived);
}
}}}
Of course this begs the question as to how serialization for
boost::enable_shared_from_this<Derived> should be implemented. Of hand I
don't remember what boost::enable_shared_from_this<Derived>does right now.
( could guess but I'm not going to waste your time). So my advice is to
figure out how to implement serialization for
boost::enable_shared_from_this<Derived> and re-submit.
maybe something like the following would work
{{{
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
boost_shared_ptr<Derived> m_sp = shared_from_this;
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
ar & BOOST_SERIALIZATION_NVP(m_sp);
ar & BOOST_SERIALIZATION_NVP(m_derived);
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9567#comment:3> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC