我序列化併發送一個對象的原始指針到另一個應用程序。Boost:序列化:誰清除了反序列化的數據?
當反序列化我得到另一個原始指針。這意味着Boost :: Serialization在內部構造這個指針背後的對象。我現在好奇誰擁有對象的所有權,如果Boost將刪除該對象,如果它不再需要。
一些代碼,也許更能說明問題的是什麼:
void anyMethod()
{
std::ifstream file("archiv.txt");
boost::archive::text_iarchive ia(file);
AnyClass* object;
ia >> object;
//work with object
}
//Now what has happened to object?
//Is it deleted, cause it went out of scope?
//Do I have to delete it myself?
你可能需要清理自己。一般來說C++是非常重要的,如果你想花費時間完成某件事情,明確地說你想花費時間。 – thecoshman 2010-11-08 07:29:17