3
首先,現在boost :: serialization是否支持unordered_set?我沒有找到頭文件boost/serialization/unordered_set.hpp。編譯序列化boost :: unordered_set錯誤
這裏是我試圖執行代碼:
namespace boost {
namespace serialization{
template<class Archive, typename T, typename H, typename P, typename A>
void save(Archive &ar,
const unordered::unordered_set<T,H,P,A> &s, const unsigned int) {
vector<T> vec(s.begin(),s.end());
ar<<vec;
}
template<class Archive, typename T, typename H, typename P, typename A>
void load(Archive &ar,
unordered::unordered_set<T,H,P,A> &s, const unsigned int) {
vector<T> vec;
ar>>vec;
std::copy(vec.begin(),vec.end(),
std::inserter(s,s.begin()));
}
template<class Archive, typename T, typename H, typename P, typename A>
void serialize(Archive &ar,
unordered::unordered_set<T,H,P,A> &s, const unsigned int version) {
boost::serialization::split_free(ar,s,version);
}
}
}
以下是錯誤:
'class std::vector<int, std::allocator<int> >' has no member named 'serialize'
另外,我還有以下代碼警告:
boost::archive::text_oarchive(ss)<<s1;
Warning:comparison between signed and unsigned integer expressions [-Wsign-compare]
我不確定是否可以忽略它。
你試過'boost/serialization/hash_set.hpp'嗎? – TemplateRex 2013-05-01 09:19:55
@rhalbersma我嘗試了很多錯誤。 '在成員函數中'void boost :: serialization :: stl :: archive_input_hash_set :: operator()(Archive&,Container&,unsigned int)':' - 'stack_construct'不是'boost: :serialization :: detail'等等。 –
user957121
2013-05-01 09:49:15
我通過包括解決了這個問題<升壓/串行化/ vector.hpp> 由於[此篇] [1] [1]:http://stackoverflow.com/a/9437157/957121 – user957121 2013-05-04 07:24:21