-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (27 loc) · 752 Bytes
/
main.cpp
File metadata and controls
34 lines (27 loc) · 752 Bytes
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
#include <fstream>
#include <iostream>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include "vect_container.hpp"
int main(int argc, char **argv) {
VectContainer<int> vv;
for (int n : {0, 1, 2, 3, 4, 5}) vv.elements.push_back(n);
// Save VectContainer data to archive
{
std::ofstream ofs("temp.dat");
boost::archive::text_oarchive ar(ofs);
// Save the data
ar &vv;
}
// Restore from saved data and print to verify contents
VectContainer<int> vv_restore;
{
// Create and input archive
std::ifstream ifs("temp.dat");
boost::archive::text_iarchive ar(ifs);
// Load the data
ar &vv_restore;
}
std::cout << (vv_restore == vv) << std::endl;
return 0;
}