ビルドしたいコードがいくつかあります。このコードは、boost::ptr_map クラスを使用して特定のオブジェクトをシリアル化します。私はboost1.38でVisual Studio 2008を使用していますが、コンパイラから次のエラーが発生しています。他の誰かがこのようなものを見たのだろうか。
C2039: 'serialize' : 'boost::ptr_map' のメンバーではありません
一部の参照が欠落しているように見えますが、それが何なのか疑問に思っています。boost/serialization/ptr_map が表示されません。私はたくさんグーグルで検索しましたが、実行可能であることが証明されたものは何もありません. 以下に同じエラーを生成するサンプルコードを作成しました
#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;
}
どんな助けでも大歓迎です。