boost-serialization

Deserializing constructor doesn't read data correctly

烂漫一生 提交于 2019-11-27 07:37:54
问题 I am trying to deserialize an object that does not have a default constructor. I've seen that you can do this by passing an archive to a constructor. However, when I do this it does not seem to read the data correctly? Here is an example - Works() outputs "1 2" as it should (using a default constructor and the operator>>), but DoesntWork() outputs "0 0". I've stepped through and everything seems to be getting called appropriately. Can anyone explain the difference between these two functions?

How can boost::serialization be used with std::shared_ptr from C++11?

只愿长相守 提交于 2019-11-27 01:31:50
问题 I know that there is a Boost module for serialization of boost::shared_ptr, but I cannot find anything for std::shared_ptr. Also, I don't know how to implement it easily. I'm afraid that the following code namespace boost{namespace serialization{ template<class Archive, class T> inline void serialize(Archive & ar, std::shared_ptr<T> &t, const unsigned int version) { if(Archive::is_loading::value) {T*r;ar>>r;t=r;} else {ar<<t.get();} } }}//namespaces doesn't work. Indeed, if some object was

boost serialization, deserialization of raw C arrays

一曲冷凌霜 提交于 2019-11-26 23:23:59
问题 I'm trying to serialize and deserialize raw C pointers and their data, with the example below. It seems to serialize just fine, but I am unsure how to make it deserialize - it just crashes with a memory access violation exception when I deserialize it. I suppose it is because it dosn't know how to deserialize it, but where do I specify that? Using a vector is not an option, in very large primitive data amounts it is painfully slow #include <stdint.h> #include <string> #include <iostream>

Get private data members for non intrusive boost serialization C++

这一生的挚爱 提交于 2019-11-26 20:59:29
问题 I have tried providing getters of class A for my non-member serialize() function` since accessing from members is private. template<typename T> class A { public: A(const T& id) : m_id(id) {} T& getRef() { return m_id; } // not giving good results T getId() { return m_id; } // not giving good results const T& getRef() const { return m_id; } // not giving good results private: // I would like to keep it private T m_id; } namespace boost { namespace serialization { template<class Archive

how to do performance test using the boost library for a custom library

孤街醉人 提交于 2019-11-26 17:16:47
问题 I need to do performance testing of a library written in c++. The library consist of few sets of structures. I have already done the serialization test for these class but not sure how to do perfomance test for these . Below is sample of a struct in library struct X { public: int p; double q; X(); ~X(); } struct Y { float m; double n; Y(); ~Y(); } struct Z { public: std::map<std::string,boost::shared_ptr<X>> Xtype; std::map<std::string,boost::shared_ptr<Y>> Ytype; int i; string name; Z(); ~Z(