]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
2 | // demo_pimpl_A.cpp | |
3 | ||
f67539c2 | 4 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
7c673cae FG |
5 | // Use, modification and distribution is subject to the Boost Software |
6 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | #include <boost/archive/text_iarchive.hpp> | |
10 | #include <boost/archive/text_oarchive.hpp> | |
11 | ||
12 | #include "demo_pimpl_A.hpp" | |
13 | ||
14 | // "hidden" definition of class B | |
15 | struct B { | |
16 | int b; | |
17 | template<class Archive> | |
18 | void serialize(Archive & ar, const unsigned int /* file_version */){ | |
19 | ar & b; | |
20 | } | |
21 | }; | |
22 | ||
23 | A::A() : | |
24 | pimpl(new B) | |
25 | {} | |
26 | A::~A(){ | |
27 | delete pimpl; | |
28 | } | |
29 | // now we can define the serialization for class A | |
30 | template<class Archive> | |
31 | void A::serialize(Archive & ar, const unsigned int /* file_version */){ | |
32 | ar & pimpl; | |
33 | } | |
f67539c2 | 34 | |
7c673cae FG |
35 | // without the explicit instantiations below, the program will |
36 | // fail to link for lack of instantiantiation of the above function | |
37 | // note: the following failed to fix link errors for vc 7.0 ! | |
38 | template void A::serialize<boost::archive::text_iarchive>( | |
f67539c2 | 39 | boost::archive::text_iarchive & ar, |
7c673cae FG |
40 | const unsigned int file_version |
41 | ); | |
42 | template void A::serialize<boost::archive::text_oarchive>( | |
f67539c2 | 43 | boost::archive::text_oarchive & ar, |
7c673cae FG |
44 | const unsigned int file_version |
45 | ); |