Ticket #2286: test.cxx

File test.cxx, 706 bytes (added by Ross Lippert <ross.lippert@…>, 14 years ago)

test program

Line 
1#include <fstream>
2#include <boost/archive/text_oarchive.hpp>
3#include <boost/archive/text_iarchive.hpp>
4
5/////////////////////////////////////////// Singleton class
6class C {
7 int x,y,z;
8
9 C() : x(1),y(2),z(3) {}
10
11 friend class boost::serialization::access;
12 template <typename A>
13 void serialize(A &a,unsigned v) { a & x & y & z; }
14
15 //public: //<-- won't compile unless this is public
16 ~C() {}
17
18public:
19 static C & Instance() {
20 static C c;
21 return c;
22 }
23};
24
25/////////////////////////////////////////////////////////////
26int main() {
27 // create and open a character archive for output
28 std::ofstream ofs("filename");
29
30 boost::archive::text_oarchive oa(ofs);
31 oa << C::Instance();
32}