[Serialization] serialization of shared_ptr with custom deleter
Hi
I am using boost 1.49. There is problem with serialization of shared_ptr
with custom deleter, it doesnot preserve the deleter. After deserialization
of shared_ptr with custom deleter, when using boost::get_deleter on the
deserialized shared_ptr it returns null. Here is code example
struct DetachTest
{
~DetachTest()
{
int debug =0;
}
friend class boost::serialization::access;
template<class Archive>
inline void serialize(Archive & ar,
const unsigned int file_version)
{
}
};
{
boost::shared_ptr<DetachTest> ss(new
DetachTest,SmartDeleter<DetachTest>());
std::ofstream ofs("C:\\detach.xml");
boost::archive::xml_oarchive oa(ofs);
oa & boost::serialization::make_nvp("detach",ss);
}
{
DetachTest* test = 0;
boost::shared_ptr<DetachTest> ss (test,SmartDeleter<DetachTest>());
//del is nonnul here
SmartDeleter<DetachTest>* del =
boost::get_deleter
double check that this is not a feature of shared pointer. Perhaps figure out a patch open up a trac item. Robert Ramey -- View this message in context: http://boost.2283326.n4.nabble.com/Serialization-serialization-of-shared-ptr... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
Elizabeta
-
Robert Ramey