|
Boost Users : |
Subject: [Boost-users] Reduced example
From: Alexander Gutenev (gutenev_at_[hidden])
Date: 2009-12-14 12:07:05
#include <string>
#include <sstream>
#include <boost/smart_ptr.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
struct X
: boost::enable_shared_from_this<X>
{
X(){}
virtual ~X() {}
explicit X(int i) : i(i) {}
template<class Archive>
void serialize(Archive & ar, const unsigned int)
{
ar & boost::serialization::make_nvp("i", i);
}
int i;
};
typedef boost::shared_ptr<X> PX;
int main()
{
std::stringstream ss;
boost::archive::xml_oarchive oa(ss);
PX px (new X(4));
oa << boost::serialization::make_nvp("v", px);
px.reset();
ss.seekp(0);
boost::archive::xml_iarchive ia(ss);
ia >> boost::serialization::make_nvp("v", px);
PX px1 = px.get()->shared_from_this();
}
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