1/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2// test_polymorphic_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 "test_polymorphic_A.hpp"
10#include <boost/serialization/nvp.hpp>
11
12#include "A.hpp"
13#include "A.ipp"
14
15data::data() :
16 a(new A)
17{}
18data::~data(){
19 delete a;
20}
21
22bool data::operator==(const data & rhs) const {
23 return * (a) == *(rhs.a);
24}
25
26#if 0 // this method fails with msvc 6.0 and borland
27// now we can define the serialization for class A
28template<class Archive>
29void data::serialize(Archive & ar, const unsigned int /* file_version */){
30 ar & BOOST_SERIALIZATION_NVP(a);
31}
32
33// without the explicit instantiation below, the program will
34// fail to link for lack of instantiation of the above function
35// note: the following failed to fix link errors for vc 7.0 !
36#include <boost/archive/polymorphic_oarchive.hpp>
37
38template void data::serialize<boost::archive::polymorphic_oarchive>(
39 boost::archive::polymorphic_oarchive & ar,
40 const unsigned int file_version
41);
42
43#include <boost/archive/polymorphic_iarchive.hpp>
44
45template void data::serialize<boost::archive::polymorphic_iarchive>(
46 boost::archive::polymorphic_iarchive & ar,
47 const unsigned int file_version
48);
49#endif
50
51// so use this
52void data::serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int /* file_version */){
53 ar & BOOST_SERIALIZATION_NVP(a);
54}
55
56void data::serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int /* file_version */){
57 ar & BOOST_SERIALIZATION_NVP(a);
58}
59

source code of boost/libs/serialization/test/test_polymorphic_A.cpp