forked from rncarpio/bellman
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest1.cpp
More file actions
61 lines (54 loc) · 1.94 KB
/
test1.cpp
File metadata and controls
61 lines (54 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Copyright (c) 2011 Ronaldo Carpio
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appear in all copies and
// that both that copyright notice and this permission notice appear
// in supporting documentation. The authors make no representations
// about the suitability of this software for any purpose.
// It is provided "as is" without express or implied warranty.
//
#include <iostream>
#include <fstream>
#include <boost/shared_ptr.hpp>
#include <boost/filesystem.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
using namespace std;
using boost::shared_ptr;
using namespace boost::filesystem;
using namespace boost::archive;
template<class Archive>
class Parent {
friend class boost::serialization::access;
virtual void save(Archive & ar,const unsigned int version) const
{cout<<"Parent::save"<<endl;}
virtual void load(Archive & ar,const unsigned int version)
{cout<<"Parent::load"<<endl;}
BOOST_SERIALIZATION_SPLIT_MEMBER()
public:
Parent() {cout<<"Parent()"<<endl;}
virtual ~Parent() {cout<<"~Parent()"<<endl;}
};
template<class Archive>
class Child : public Parent<Archive> {
friend class boost::serialization::access;
void save(Archive & ar,const unsigned int version) const
{cout<<"Child::save"<<endl;}
void load(Archive & ar,const unsigned int version)
{cout<<"Child::load"<<endl;}
BOOST_SERIALIZATION_SPLIT_MEMBER()
public:
Child() {cout<<"Child()"<<endl;}
~Child() {cout<<"~Child()"<<endl;}
};
int main()
{
boost::shared_ptr<Parent<text_oarchive>> p(new Child<text_oarchive>());
ofstream out("test.txt");
text_oarchive ofs(out);
ofs << *p;
}