我試圖序列具有類成員變量一樣的std :: list類> LSS如何使用boost系列化
#include <boost/serialization/optional.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/list.hpp>
struct SomeStruct
{
int x;
double y;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive &at, const unsigned int version)
{
at & x;
at & y;
}
};
class BuildTest
{
std::list<boost::shared_ptr<SomeStruct *>> lss ;
std::string name;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive &at, const unsigned int version)
{
at & lss; // is this sufficient to serialize lss ?
at & name;
}
}
我已經添加了所有需要的頭序列化類型的shared_ptr指針類型的列表升壓序列化文件。有類似的問題,但通過適當的答案how do i serialize list variable of type <boost::shared_ptr<void *>>
請出示頭。你是否包含'boost/serialization/list.hpp',boost/serialization/shared_ptr.hpp'? –
@DieterLücking - 添加代碼中使用的所有頭文件。 – manu
是否爲SomeStruct編寫了序列化代碼? –