Ticket #7013: versioning.cpp

File versioning.cpp, 777 bytes (added by shaderaider@…, 10 years ago)

Source code example of broken versioning

Line 
1#include <boost/serialization/nvp.hpp>
2#include <boost/archive/xml_oarchive.hpp>
3#include <iostream>
4
5using namespace std;
6using namespace boost::archive;
7
8class Nested {
9public:
10 explicit Nested()
11 : mC()
12 { }
13
14 explicit Nested(char c)
15 : mC(c)
16 { }
17
18private:
19 friend class boost::serialization::access;
20
21 template<class Archive>
22 void serialize(Archive& ar, const unsigned int)
23 {
24 using boost::serialization::make_nvp;
25 ar & make_nvp("c", mC);
26 };
27
28private:
29 char mC;
30};
31
32BOOST_CLASS_VERSION(Nested, 0);
33
34int main()
35{
36 Nested n('c');
37
38 {
39 using boost::serialization::make_nvp;
40 xml_oarchive ar(cout);
41 ar << make_nvp("Nested", n);
42 }
43
44 return 0;
45}