boost-serialization

Error using boost serialization with binary archive

南笙酒味 提交于 2021-02-18 17:12:49
问题 I get the following error while reading from boost::archive::binary_iarchive into my variable: test-serialization(9285,0x11c62fdc0) malloc: can't allocate region *** mach_vm_map(size=18014398509486080) failed (error code=3) test-serialization(9285,0x11c62fdc0) malloc: *** set a breakpoint in malloc_error_break to debug My serialization and deserialization code are: template<class Archive> void save(Archive & archive, const helib::PubKey & pubkey, const unsigned int version){ BOOST_TEST

Error using boost serialization with binary archive

别来无恙 提交于 2021-02-18 17:12:12
问题 I get the following error while reading from boost::archive::binary_iarchive into my variable: test-serialization(9285,0x11c62fdc0) malloc: can't allocate region *** mach_vm_map(size=18014398509486080) failed (error code=3) test-serialization(9285,0x11c62fdc0) malloc: *** set a breakpoint in malloc_error_break to debug My serialization and deserialization code are: template<class Archive> void save(Archive & archive, const helib::PubKey & pubkey, const unsigned int version){ BOOST_TEST

De-Serializing an STL map class member

佐手、 提交于 2021-02-09 11:37:47
问题 I am new to boost & boost serialization. I am trying to de-serialize a STL map class member. Here is the code : ... class Face { friend std::ostream & operator<<(std::ostream &os, const Face &mf); friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int /* file_version */){ ar & mFaceID; } public: size_t mFaceID; /*!< an integer value represents the Face Identification number */ void setFaceId(const size_t& faceID) { mFaceID = faceID;

How does boost::serialization allocate memory when deserializing through a pointer?

假如想象 提交于 2021-01-28 11:51:08
问题 In short, I'd like to know how boost::serialization allocates memory for an object when deserializing through a pointer. Below, you'll find an example of my question, clearly illustrated alongside companion code. This code should be fully functional and compile fine, there are no errors, per se, just a question on how the code actually works. #include <cstddef> // NULL #include <iomanip> #include <iostream> #include <fstream> #include <string> #include <boost/archive/text_iarchive.hpp>

Derived class offset calculation in boost::serialization. Is it valid?

巧了我就是萌 提交于 2021-01-27 14:05:37
问题 boost::serialization contains this code: reinterpret_cast<std::ptrdiff_t>( static_cast<Derived *>( reinterpret_cast<Base *>(1 << 20) ) ) - (1 << 20) Its purpose is to calculate an offset between base and derived classes. Is this code free of undefined behaviour? The reason why I am asking is that ASAN+UBSAN complain. For example, this code #include <iostream> class Foo { public: virtual void foo() {} }; class Base { public: virtual void base() {} }; class Derived: public Foo, public Base {};

Boost serialization doesn't work with shared_ptr<int>

拜拜、爱过 提交于 2020-07-03 07:18:04
问题 The following piece of code compiles just fine: #include <boost/serialization/shared_ptr.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <sstream> #include <memory> struct A { int i; A(): i(0) {} A(int i): i(i) {} template <typename Archive> void serialize(Archive& ar, const unsigned int) { ar & i; } }; int main() { auto a = std::make_shared<A>(465); std::stringstream stream; boost::archive::text_oarchive out{stream}; out << a; } Now I would

Boost serializing armadillo matrices

喜欢而已 提交于 2020-05-16 20:55:07
问题 I'm trying to make sure serializing works for matrices i.e. Armadillo and I'm getting some errors. I made a simple example of a random matrix and am trying to save the content using boost in a binary file, then load it using boost: #include <iostream> #include <fstream> #include <boost/archive/tmpdir.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> #include <armadillo> int main() { arma::mat A = arma::randu<arma::mat>(4,5); std::ofstream

Boost serialization performance: text vs. binary format

匆匆过客 提交于 2020-02-21 10:37:46
问题 Should I prefer binary serialization over ascii / text serialization if performance is an issue? Has anybody tested it on a large amount of data? 回答1: I used boost.serialization to store matrices and vectors representing lookup tables and some meta data (strings) with an in memory size of about 200MByte. IIRC for loading from disk into memory it took 3 minutes for the text archive vs. 4 seconds using the binary archive on WinXP. 回答2: Benchmarked it for a problem involving loading a large

Boost serialization performance: text vs. binary format

≯℡__Kan透↙ 提交于 2020-02-21 10:36:13
问题 Should I prefer binary serialization over ascii / text serialization if performance is an issue? Has anybody tested it on a large amount of data? 回答1: I used boost.serialization to store matrices and vectors representing lookup tables and some meta data (strings) with an in memory size of about 200MByte. IIRC for loading from disk into memory it took 3 minutes for the text archive vs. 4 seconds using the binary archive on WinXP. 回答2: Benchmarked it for a problem involving loading a large

Linker errors when using boost serialization

╄→гoц情女王★ 提交于 2020-02-19 09:48:51
问题 I am using boost serialization. I compiled with: -L/opt/local/lib -lboost_serialization -stdlib=libc++ , but got several (ungooglable) errors: Undefined symbols for architecture x86_64: "boost::archive::text_oarchive_impl::save(std::__1::basic_string, std::__1::allocator > const&)", referenced from: void boost::archive::save_access::save_primitive, std::__1::allocator > >(boost::archive::text_oarchive&, std::__1::basic_string, std::__1::allocator > const&) in main.o "boost::archive::basic