Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/serialization/example/demo_pimpl_A.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.3 KB
Line 
1/////////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);
Note: See TracBrowser for help on using the repository browser.