I tried to switch back to boost 1.56.0 and there it works!
On 14 Apr 2015, at 06:21, Robert Ramey
wrote: I ran a modified version of this program on my Mac OS system and it worked as I would expect. I'm running the latest version of the serialization library
Robert Ramey
my version:
//#include
//#include #include <fstream> #include "test_tools.hpp" #include #include #include #include class SOBJ { public: friend class boost::serialization::access; virtual void SerializationHelperFcn() {} SOBJ() { std::cout << "SOBJ Constructor" << std::endl; }
virtual ~SOBJ() { std::cout << "SOBJ Destructor" << std::endl; } double value=0.; template<typename Archive> void serialize(Archive &ar, const unsigned int ver) { ar & boost::serialization::make_nvp("value", value); } };
void shared_ptr_serialization_test() { const char * testfile = boost::archive::tmpnam(NULL); boost::shared_ptr<SOBJ> out=boost::make_shared<SOBJ>();
{ //boost::iostreams::filtering_ostream ofs;
//ofs.push(boost::iostreams::file_descriptor_sink("/Users/juhe/stest.xml")); std::ofstream ofs(testfile); boost::archive::xml_oarchive oa(ofs); oa << boost::serialization::make_nvp("tag", out); }
boost::shared_ptr<SOBJ> in=nullptr;
{ // boost::iostreams::filtering_istream ifs; // ifs.push(boost::iostreams::file_descriptor_source("/Users/juhe/stest.xml")); std::ifstream ifs(testfile); boost::archive::xml_iarchive ia(ifs); ia >> boost::serialization::make_nvp("tag", in); }
std::cout << "out.use_count()=" << out.use_count() << std::endl; std::cout << "in.use_count() =" << in.use_count() << std::endl; }
int test_main(int argc, char * argv[]){ shared_ptr_serialization_test(); return 0; } /raw>
-- View this message in context: http://boost.2283326.n4.nabble.com/Serialization-of-boost-shared-ptr-wrong-r... Sent from the Boost - Users mailing list archive at Nabble.com. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users