-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi! Am 13.03.12 20:39, schrieb Robert Ramey:
I posted a example - did this not work?
It worked for me using Boost 1.47. The code below can output or input
serialization data. It links to Boost.Serialization of course. I
tested it by running it twice and piping the output of the first into
the input of the second instance:
$dist/test 1 | dist/test 2
1
Frank
///// Main.cpp:
#include <vector>
struct A {
std::vector<unsigned> data;
};
struct B {
const std::vector<unsigned> * data_ptr;
};
struct C {
A a;
std::vector<B> elements;
};
template<class Archive>
void serialize(Archive &ar, A & a, const unsigned int version){
ar & a.data;
}
template<class Archive>
void serialize(Archive &ar, B & b, const unsigned int version){
ar & b.data_ptr;
}
template<class Archive>
void serialize(Archive &ar, C & c, const unsigned int version){
ar & c.a;
ar & c.elements;
}
struct Sample {
Sample();
C const& getC() { return c; }
C c;
} sample;
Sample::Sample()
{
c.a.data.push_back(5);
const B b = { &c.a.data };
c.elements.resize(2, b);
}
#include