| 1 | #include <sstream>
|
|---|
| 2 | #include <boost/serialization/serialization.hpp>
|
|---|
| 3 | #include <boost/archive/binary_oarchive.hpp>
|
|---|
| 4 |
|
|---|
| 5 | class base
|
|---|
| 6 | {
|
|---|
| 7 | friend class boost::serialization::access;
|
|---|
| 8 | template<class Archive>
|
|---|
| 9 | void serialize(Archive & ar, const unsigned int version)
|
|---|
| 10 | {
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | public:
|
|---|
| 14 | base()
|
|---|
| 15 | {}
|
|---|
| 16 |
|
|---|
| 17 | virtual ~base() throw()
|
|---|
| 18 | {}
|
|---|
| 19 | };
|
|---|
| 20 |
|
|---|
| 21 | class derived : public base
|
|---|
| 22 | {
|
|---|
| 23 | friend class boost::serialization::access;
|
|---|
| 24 | template<class Archive>
|
|---|
| 25 | void serialize(Archive & ar, const unsigned int version)
|
|---|
| 26 | {
|
|---|
| 27 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(base);
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | public:
|
|---|
| 31 | derived()
|
|---|
| 32 | {
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | virtual ~derived() throw()
|
|---|
| 36 | {
|
|---|
| 37 | }
|
|---|
| 38 | };
|
|---|
| 39 |
|
|---|
| 40 | int main(void)
|
|---|
| 41 | {
|
|---|
| 42 | derived something;
|
|---|
| 43 |
|
|---|
| 44 | std::ostringstream out;
|
|---|
| 45 | boost::archive::binary_oarchive oa(out);
|
|---|
| 46 | oa << something;
|
|---|
| 47 |
|
|---|
| 48 | return 0;
|
|---|
| 49 | }
|
|---|