I'm trying to serialize a std::shared_ptr using a polymorphic archive
interface, but it complains about no "get_helper".
Specifically clang states:
"/boost_1_56_0/boost/serialization/shared_ptr.hpp:253:21:
No member named 'get_helper' in 'boost::archive::polymorphic_iarchive'"
I tried including "boost/serialization/shared_ptr_helper.hpp", but this
didn't seem to have what I needed.
I did see the new stuff in "boost/serialization/shared_ptr.hpp" regarding
std::shared_ptr<>, so I'm hopeful.
Most of what I'm doing requires the serialization code to be inside of
dll's or dylibs, so I believe I'm going down the correct path in using
polymorphic archives...
void save(std::shared_ptr<developer> p)
{
std::ofstream of("archiv.txt");
boost::archive::polymorphic_text_oarchive oa(of);
boost::archive::polymorphic_oarchive & oa_interface = oa;
oa_interface << p;
}
void load()
{
std::ifstream i("archiv.txt");
boost::archive::polymorphic_text_iarchive ia(i);
boost::archive::polymorphic_iarchive & ia_interface = ia;
std::shared_ptr<developer> p;
ia_interface >> p;
std::cout << p->getName() << std::endl;
std::cout << p->age() << std::endl;
std::cout << p->language() << std::endl;
std::cout << p->getLangVer() << std::endl;
}
The compiler error specifically points to this function in shared_ptr.hpp
template
inline void load(
Archive & ar,
std::shared_ptr< T > &t,
const unsigned int /*file_version*/
){
// The most common cause of trapping here would be serializing
// something like shared_ptr<int>. This occurs because int
// is never tracked by default. Wrap int in a trackable type
BOOST_STATIC_ASSERT((tracking_level< T >::value != track_never));
T* r;
ar >> boost::serialization::make_nvp("px", r);
boost::serialization::shared_ptr_helperstd::shared_ptr & h =
ar.template get_helper<
shared_ptr_helperstd::shared_ptr
>();
h.reset(t,r);
}
Any suggestions?