Boost logo

Boost Users :

Subject: [Boost-users] serializing ptr_map results in compiler error C2039
From: Faheemullah Memon (faheemitian_at_[hidden])
Date: 2009-06-10 18:01:31


I have some code that I want to build. The code uses boost::ptr_map class to serialize certain objects. I have Visual Studio 2008 with boost1.38 and I am getting following error from compiler. I wonder if any one else has seen any thing like this. C2039: 'serialize' : is not a member of 'boost::ptr_map<Key,T>' Looks like some reference is missing and I wonder what it is, I don't see any boost/serialization/ptr_map. I have Googled a lot and nothing has proved to be viable. I have created a sample code that generates the same error below #include <fstream> #include <iostream> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/config.hpp> #include <boost/shared_ptr.hpp> #include <boost/ptr_container/ptr_map.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/version.hpp> #include <boost/serialization/split_member.hpp> using namespace std; class User { boost::ptr_map<std::string,
 string> ptrmap; public: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & ptrmap; } bool save(const std::string& filename) { ofstream ofs(filename.c_str()); if(ofs.good() == false) { return false; } try { boost::archive::text_oarchive oa(ofs); oa << (*this); } catch(...) { throw; } return true; } }; int main() { User user; user.save("C:\\test.db"); return EXIT_SUCCESS; } Any help is appreciated.

faheemitian

      



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