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