I don't see any problem with the code snippet. Maybe you want to make small test which we run here. Robert Ramey gast128 wrote:
Robert Ramey
writes: To my mind, the best solution is to use smart_pointers and serialize them.
Hello Robert,
this gives me another problem (crash) when using an object consisting of two shared pointers:
struct Bla { template <class Archive> void serialize(Archive& ar, const unsigned int /*version*/) { ar & BOOST_SERIALIZATION_NVP(m_ptr); ar & BOOST_SERIALIZATION_NVP(m_ptr1); }
boost::shared_ptr<int> m_ptr; boost::shared_ptr<int> m_ptr1; };
If I try to load this, and let if fail while loading the second shared pointer (because the file is corrupt) it crashes when using the 'delete_created_pointers' option in the catch handler due to the fact that the shared pointer wants to cleanup an already deleted pointer. Leaving this option out does not crash it anymore, but results in some memory leaks.
But maybe I am taking now the serialziation library beyond its design limits. These are all of course exceptional case.
wkr, me