blob: 455b71ece3027e09221966bcb19357b3d525f4fc [file] [log] [blame]
Brian Silverman88678712018-08-04 23:56:48 -07001/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2// demo_pimpl_A.cpp
3
4// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
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
15struct B {
16 int b;
17 template<class Archive>
18 void serialize(Archive & ar, const unsigned int /* file_version */){
19 ar & b;
20 }
21};
22
23A::A() :
24 pimpl(new B)
25{}
26A::~A(){
27 delete pimpl;
28}
29// now we can define the serialization for class A
30template<class Archive>
31void A::serialize(Archive & ar, const unsigned int /* file_version */){
32 ar & pimpl;
33}
34
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 !
38template void A::serialize<boost::archive::text_iarchive>(
39 boost::archive::text_iarchive & ar,
40 const unsigned int file_version
41);
42template void A::serialize<boost::archive::text_oarchive>(
43 boost::archive::text_oarchive & ar,
44 const unsigned int file_version
45);