2

I'm trying to serialize a boost::shared_ptr to a custom archive. The main problem I'm facing is that the boost::serialization code for shared_ptr requires the archive to have both a 'reset' and an 'append' method.

Does anyone know where these methods are documented? The Archive Concept in boost says nothing about these methods (or at least I wasn't able to find anything), and could not even find the declarations of such methods on text_iarchive (or base classes). However, usage of text_iarchive is possible without any problems.

On the other hand, with my own archive the code would not compile:

class my_iarchive : public boost::archive::detail::common_iarchive<my_iarchive> {
    // load, load_binary, load_override, etc. ...
};

/usr/include/boost/serialization/shared_ptr.hpp:139:5: error: ‘class my_iarchive’ has no member named ‘reset’

Answer ( courtesy of Tawnos )

#include <boost/archive/shared_ptr_helper.hpp>

class my_iarchive : public boost::archive::detail::common_iarchive<my_iarchive>,
                    public boost::archive::detail::shared_ptr_helper {
     //load, load archive, etc.
};
Silviu P
  • 41
  • 2
  • Does this help? http://www.boost.org/doc/libs/1_53_0_beta1/boost/archive/shared_ptr_helper.hpp It has definitions for both reset and append. – Tawnos Mar 10 '13 at 00:48

0 Answers0