Port project VS2003 -> VS2013 error C2039 serialize is not a member of hash_Map

483 views Asked by At

trying to update some of my company's software from visual studio 2003 to 2013. We use a lot of libraries that had to be transplanted from a different location, but after taking care of all the boost copying and adding it to C++ additional include directories, I still get the following error.

error C2039" 'serialize' : is not a member of 'stdext::hash_map Key,Data,Hash_Traits,std::allocator>'

This error occurs in access.hpp in boost/serialization.

Due to intellectual property things, I can't actually include any of my code, but any help would be greatly appreciated.

Thanks

1

There are 1 answers

0
sehe On

You should make your container class serializable, by implementing the customization points.

I'm going to assume you upgrade to std::unordered_map (because you should) and then you can follow the code I wrote here: C++ Boost.Serialization error for hash_map with custom objects as key

Note I define serialization for std::unordered_map so you no longer have to use deprecated GNU/MSVC library extensions. (see also this bug-report/patch)

#include <unordered_map>
#include <boost/serialization/collections_save_imp.hpp>
#include <boost/serialization/collections_load_imp.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/split_free.hpp>

namespace boost { namespace serialization {

    template<class Archive, typename... TArgs >
        inline void save(Archive & ar, std::unordered_map<TArgs...> const&t, unsigned) {
            boost::serialization::stl::save_collection<Archive, std::unordered_map<TArgs...> >(ar, t);
        }

    template<class Archive, typename... TArgs >
        inline void load(Archive & ar, std::unordered_map<TArgs...> &t, unsigned) {
            boost::serialization::stl::load_collection<Archive,
                std::unordered_map<TArgs...>,
                boost::serialization::stl::archive_input_map<
                    Archive, std::unordered_map<TArgs...> >,
                boost::serialization::stl::no_reserve_imp<std::unordered_map<TArgs...> >
                    >(ar, t);
        }

    // split non-intrusive serialization function member into separate
    // non intrusive save/load member functions
    template <class Archive, typename... TArgs>
        inline void serialize(Archive & ar, std::unordered_map<TArgs...> &t, unsigned file_version) {
            boost::serialization::split_free(ar, t, file_version);
        }
} }