Ticket #3412: MemLeakSerialization.cpp

File MemLeakSerialization.cpp, 1.5 KB (added by Runar Undheim <r.undheim@…>, 13 years ago)
Line 
1#include <stdio.h>
2#include <tchar.h>
3#include <crtdbg.h>
4
5
6#include <boost/archive/binary_oarchive.hpp>
7#include <boost/serialization/export.hpp>
8
9class Base {
10 friend class boost::serialization::access;
11 template<class Archive>
12 void serialize(Archive & ar, const unsigned int version)
13 { }
14
15 virtual void vTest(
16 ) { }
17};
18
19class Level1 : public Base {
20 friend class boost::serialization::access;
21 template<class Archive>
22 void serialize(Archive & ar, const unsigned int version)
23 { ar & boost::serialization::base_object<Base>(*this); }
24};
25
26class Level2 : public Level1 {
27 friend class boost::serialization::access;
28 template<class Archive>
29 void serialize(Archive & ar, const unsigned int version)
30 { ar & boost::serialization::base_object<Level1>(*this); }
31};
32
33class Level3 : public Level2 {
34 friend class boost::serialization::access;
35 template<class Archive>
36 void serialize(Archive & ar, const unsigned int version)
37 { ar & boost::serialization::base_object<Level2>(*this); }
38};
39
40class Level4 : public Level3 {
41 friend class boost::serialization::access;
42 template<class Archive>
43 void serialize(Archive & ar, const unsigned int version)
44 { ar & boost::serialization::base_object<Level3>(*this); }
45};
46
47BOOST_CLASS_EXPORT(Base)
48BOOST_CLASS_EXPORT(Level1)
49BOOST_CLASS_EXPORT(Level2)
50BOOST_CLASS_EXPORT(Level3)
51BOOST_CLASS_EXPORT(Level4)
52
53int _tmain(int argc, _TCHAR* argv[])
54{
55 _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
56 return 0;
57}