Boost logo

Boost Users :

Subject: [Boost-users] [Serialization] 1.56.0 - polymorphic archive saving std::shared_ptr<>, no member named "get_helper"
From: Todd Seiler (todd.seiler_at_[hidden])
Date: 2014-08-15 12:50:35


I'm trying to serialize a std::shared_ptr using a polymorphic archive
interface, but it complains about no "get_helper".

Specifically clang states:
"<removed_for_posting>/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<class Archive, class T>
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_helper<std::shared_ptr> & h =
        ar.template get_helper<
            shared_ptr_helper<std::shared_ptr>
>();
    h.reset(t,r);
}

Any suggestions?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net