"elizabeta petreska" wrote in message
news:ff8898bd0911250648l9bdd3a3g47408714e88bebf3@mail.gmail.com...
Hello
I can't compile my simple project for serializing shared_ptr . I read the
archives and google it and still can't compile it :)
I am doing the following :...
I compiled your program slightly modified on my boost 1.41 system with no
problems:
/////A.h
#pragma once
#include <fstream>
#include
#include
#include
#include
class A
{
public:
A(int k):
mk(k)
{}
A(){}
template<class Archive>
void save(Archive & ar, const unsigned int version) const
{
using boost::serialization::make_nvp;
ar & BOOST_SERIALIZATION_NVP(mk);
}
template<class Archive>
void load(Archive & ar, const unsigned int version)
{
using boost::serialization::make_nvp;
ar & BOOST_SERIALIZATION_NVP(mk);
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
int mk;
};
BOOST_SERIALIZATION_SHARED_PTR(A)
///func.cpp
//#include "A.h"
void func()
{
//std::ofstream ofs(L"C:\\boostarchiveSharedPtr.xml");
//std::ifstream ifs(L"C:\\boostarchiveSharedPtr.xml");
std::ofstream ofs("C:\\boostarchiveSharedPtr.xml");
std::ifstream ifs("C:\\boostarchiveSharedPtr.xml");
boost::shared_ptr<A> bPtr(new A(13));
{
using boost::serialization::make_nvp;
boost::archive::xml_oarchive oa(ofs);
oa & BOOST_SERIALIZATION_NVP(bPtr);
}
boost::shared_ptr<A> rbPtr;
{
using boost::serialization::make_nvp;
boost::archive::xml_iarchive ia(ifs);
ia & BOOST_SERIALIZATION_NVP(rbPtr);
}
}