Ticket #2984: boost_serialize_protected_bug_minimal_2.cc

File boost_serialize_protected_bug_minimal_2.cc, 1.0 KB (added by Eric Moyer <eric_moyer@…>, 13 years ago)

I removed one of the classes -- making the minimal even smaller

Line 
1#include <iostream>
2#include <fstream>
3#include <boost/archive/text_oarchive.hpp>
4#include <boost/archive/text_iarchive.hpp>
5#include <boost/serialization/export.hpp>
6#include <boost/serialization/base_object.hpp>
7
8using namespace boost;
9using namespace std;
10
11class Base1{
12 friend class boost::serialization::access;
13public:
14 Base1(){}
15 virtual void print(){ cout << "Base1" << endl;}
16private:
17 template<class Archive>
18 void serialize(Archive & ar, const unsigned int version){}
19};
20
21BOOST_CLASS_EXPORT_GUID(Base1,"bugtry.Base1")
22
23
24class Derived:protected Base1{
25 friend class boost::serialization::access;
26public:
27 Derived(){};
28 virtual void print(){ cout << "Derived" << endl;}
29private:
30 template<class Archive>
31 void serialize(Archive & ar, const unsigned int version){
32 ar & boost::serialization::base_object<Base1>(*this);
33 }
34};
35
36BOOST_CLASS_EXPORT_GUID(Derived,"bugtry.Derived")
37
38int main(int argc,char **argv) {
39 Derived d;
40 d.print();
41 ofstream o("bugtry.out");
42 boost::archive::text_oarchive out(o);
43 out << d;
44 return 0;
45}