| 1 | #include <boost/serialization/access.hpp>
|
|---|
| 2 | #include <boost/archive/binary_oarchive.hpp>
|
|---|
| 3 | #include <fstream>
|
|---|
| 4 |
|
|---|
| 5 | class A
|
|---|
| 6 | {
|
|---|
| 7 | friend class boost::serialization::access;
|
|---|
| 8 | friend class B;
|
|---|
| 9 | private:
|
|---|
| 10 | A() {}
|
|---|
| 11 | ~A() {}
|
|---|
| 12 |
|
|---|
| 13 | template<typename Archive> void serialize(Archive& ar, const unsigned int version)
|
|---|
| 14 | {
|
|---|
| 15 | }
|
|---|
| 16 | };
|
|---|
| 17 |
|
|---|
| 18 | class B
|
|---|
| 19 | {
|
|---|
| 20 | friend class boost::serialization::access;
|
|---|
| 21 | A a;
|
|---|
| 22 |
|
|---|
| 23 | template<typename Archive> void serialize(Archive& ar, const unsigned int version)
|
|---|
| 24 | {
|
|---|
| 25 | ar << a;
|
|---|
| 26 | }
|
|---|
| 27 | };
|
|---|
| 28 |
|
|---|
| 29 | int main()
|
|---|
| 30 | {
|
|---|
| 31 | std::ofstream ofs("hi");
|
|---|
| 32 | {
|
|---|
| 33 | boost::archive::binary_oarchive oa(ofs);
|
|---|
| 34 | B b;
|
|---|
| 35 | oa << b;
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | /*
|
|---|
| 40 | 1>------ Build started: Project: 2k8test, Configuration: Release Win32 ------
|
|---|
| 41 | 1>Compiling...
|
|---|
| 42 | 1>serialization_fun.cpp
|
|---|
| 43 | 1>C:\dev\boost-trunk\boost/serialization/extended_type_info_typeid.hpp(118) : error C2248: 'A::~A' : cannot access private member declared in class 'A'
|
|---|
| 44 | 1> .\serialization_fun.cpp(16) : compiler has generated 'A::~A' here
|
|---|
| 45 | 1> .\serialization_fun.cpp(6) : see declaration of 'A'
|
|---|
| 46 | 1> C:\dev\boost-trunk\boost/serialization/extended_type_info_typeid.hpp(117) : while compiling class template member function 'void boost::serialization::extended_type_info_typeid<T>::destroy(const void *const ) const'
|
|---|
| 47 | 1> with
|
|---|
| 48 | 1> [
|
|---|
| 49 | 1> T=A
|
|---|
| 50 | 1> ]
|
|---|
| 51 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(110) : see reference to class template instantiation 'boost::serialization::extended_type_info_typeid<T>' being compiled
|
|---|
| 52 | 1> with
|
|---|
| 53 | 1> [
|
|---|
| 54 | 1> T=A
|
|---|
| 55 | 1> ]
|
|---|
| 56 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(107) : while compiling class template member function 'boost::archive::detail::oserializer<Archive,T>::oserializer(void)'
|
|---|
| 57 | 1> with
|
|---|
| 58 | 1> [
|
|---|
| 59 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 60 | 1> T=A
|
|---|
| 61 | 1> ]
|
|---|
| 62 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(234) : see reference to class template instantiation 'boost::archive::detail::oserializer<Archive,T>' being compiled
|
|---|
| 63 | 1> with
|
|---|
| 64 | 1> [
|
|---|
| 65 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 66 | 1> T=A
|
|---|
| 67 | 1> ]
|
|---|
| 68 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(228) : while compiling class template member function 'void boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard::invoke(Archive &,const T &)'
|
|---|
| 69 | 1> with
|
|---|
| 70 | 1> [
|
|---|
| 71 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 72 | 1> T=A
|
|---|
| 73 | 1> ]
|
|---|
| 74 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(292) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard' being compiled
|
|---|
| 75 | 1> with
|
|---|
| 76 | 1> [
|
|---|
| 77 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 78 | 1> T=A
|
|---|
| 79 | 1> ]
|
|---|
| 80 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(280) : while compiling class template member function 'void boost::archive::detail::save_non_pointer_type<Archive,T>::invoke(Archive &,const T &)'
|
|---|
| 81 | 1> with
|
|---|
| 82 | 1> [
|
|---|
| 83 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 84 | 1> T=A
|
|---|
| 85 | 1> ]
|
|---|
| 86 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(498) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type<Archive,T>' being compiled
|
|---|
| 87 | 1> with
|
|---|
| 88 | 1> [
|
|---|
| 89 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 90 | 1> T=A
|
|---|
| 91 | 1> ]
|
|---|
| 92 | 1> C:\dev\boost-trunk\boost/archive/detail/common_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::save<Archive,const T>(Archive &,const T &)' being compiled
|
|---|
| 93 | 1> with
|
|---|
| 94 | 1> [
|
|---|
| 95 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 96 | 1> T=A
|
|---|
| 97 | 1> ]
|
|---|
| 98 | 1> C:\dev\boost-trunk\boost/archive/array/oarchive.hpp(118) : see reference to function template instantiation 'void boost::archive::detail::common_oarchive<Archive>::save_override<const T>(T &,int)' being compiled
|
|---|
| 99 | 1> with
|
|---|
| 100 | 1> [
|
|---|
| 101 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 102 | 1> T=A
|
|---|
| 103 | 1> ]
|
|---|
| 104 | 1> C:\dev\boost-trunk\boost/archive/basic_binary_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::array::oarchive<Archive>::save_override<T>(const T &,unsigned int)' being compiled
|
|---|
| 105 | 1> with
|
|---|
| 106 | 1> [
|
|---|
| 107 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 108 | 1> T=A
|
|---|
| 109 | 1> ]
|
|---|
| 110 | 1> C:\dev\boost-trunk\boost/archive/binary_oarchive_impl.hpp(45) : see reference to function template instantiation 'void boost::archive::basic_binary_oarchive<Archive>::save_override<T>(const T &,int)' being compiled
|
|---|
| 111 | 1> with
|
|---|
| 112 | 1> [
|
|---|
| 113 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 114 | 1> T=A
|
|---|
| 115 | 1> ]
|
|---|
| 116 | 1> C:\dev\boost-trunk\boost/archive/detail/interface_oarchive.hpp(63) : see reference to function template instantiation 'void boost::archive::binary_oarchive_impl<Archive,Elem,Tr>::save_override<T>(T &,int)' being compiled
|
|---|
| 117 | 1> with
|
|---|
| 118 | 1> [
|
|---|
| 119 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 120 | 1> Elem=char,
|
|---|
| 121 | 1> Tr=std::char_traits<char>,
|
|---|
| 122 | 1> T=A
|
|---|
| 123 | 1> ]
|
|---|
| 124 | 1> .\serialization_fun.cpp(25) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<A>(T &)' being compiled
|
|---|
| 125 | 1> with
|
|---|
| 126 | 1> [
|
|---|
| 127 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 128 | 1> T=A
|
|---|
| 129 | 1> ]
|
|---|
| 130 | 1> C:\dev\boost-trunk\boost/serialization/access.hpp(109) : see reference to function template instantiation 'void B::serialize<Archive>(Archive &,const unsigned int)' being compiled
|
|---|
| 131 | 1> with
|
|---|
| 132 | 1> [
|
|---|
| 133 | 1> Archive=boost::archive::binary_oarchive
|
|---|
| 134 | 1> ]
|
|---|
| 135 | 1> C:\dev\boost-trunk\boost/serialization/serialization.hpp(81) : see reference to function template instantiation 'void boost::serialization::access::serialize<Archive,T>(Archive &,T &,const unsigned int)' being compiled
|
|---|
| 136 | 1> with
|
|---|
| 137 | 1> [
|
|---|
| 138 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 139 | 1> T=B
|
|---|
| 140 | 1> ]
|
|---|
| 141 | 1> C:\dev\boost-trunk\boost/serialization/serialization.hpp(140) : see reference to function template instantiation 'void boost::serialization::serialize<Archive,T>(Archive &,T &,const unsigned int)' being compiled
|
|---|
| 142 | 1> with
|
|---|
| 143 | 1> [
|
|---|
| 144 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 145 | 1> T=B
|
|---|
| 146 | 1> ]
|
|---|
| 147 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(147) : see reference to function template instantiation 'void boost::serialization::serialize_adl<Archive,T>(Archive &,T &,const unsigned int)' being compiled
|
|---|
| 148 | 1> with
|
|---|
| 149 | 1> [
|
|---|
| 150 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 151 | 1> T=B
|
|---|
| 152 | 1> ]
|
|---|
| 153 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(139) : while compiling class template member function 'void boost::archive::detail::oserializer<Archive,T>::save_object_data(boost::archive::detail::basic_oarchive &,const void *) const'
|
|---|
| 154 | 1> with
|
|---|
| 155 | 1> [
|
|---|
| 156 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 157 | 1> T=B
|
|---|
| 158 | 1> ]
|
|---|
| 159 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(234) : see reference to class template instantiation 'boost::archive::detail::oserializer<Archive,T>' being compiled
|
|---|
| 160 | 1> with
|
|---|
| 161 | 1> [
|
|---|
| 162 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 163 | 1> T=B
|
|---|
| 164 | 1> ]
|
|---|
| 165 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(228) : while compiling class template member function 'void boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard::invoke(Archive &,const T &)'
|
|---|
| 166 | 1> with
|
|---|
| 167 | 1> [
|
|---|
| 168 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 169 | 1> T=B
|
|---|
| 170 | 1> ]
|
|---|
| 171 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(292) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type<Archive,T>::save_standard' being compiled
|
|---|
| 172 | 1> with
|
|---|
| 173 | 1> [
|
|---|
| 174 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 175 | 1> T=B
|
|---|
| 176 | 1> ]
|
|---|
| 177 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(280) : while compiling class template member function 'void boost::archive::detail::save_non_pointer_type<Archive,T>::invoke(Archive &,const T &)'
|
|---|
| 178 | 1> with
|
|---|
| 179 | 1> [
|
|---|
| 180 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 181 | 1> T=B
|
|---|
| 182 | 1> ]
|
|---|
| 183 | 1> C:\dev\boost-trunk\boost/archive/detail/oserializer.hpp(498) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type<Archive,T>' being compiled
|
|---|
| 184 | 1> with
|
|---|
| 185 | 1> [
|
|---|
| 186 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 187 | 1> T=B
|
|---|
| 188 | 1> ]
|
|---|
| 189 | 1> C:\dev\boost-trunk\boost/archive/detail/common_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::save<Archive,const T>(Archive &,const T &)' being compiled
|
|---|
| 190 | 1> with
|
|---|
| 191 | 1> [
|
|---|
| 192 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 193 | 1> T=B
|
|---|
| 194 | 1> ]
|
|---|
| 195 | 1> C:\dev\boost-trunk\boost/archive/array/oarchive.hpp(118) : see reference to function template instantiation 'void boost::archive::detail::common_oarchive<Archive>::save_override<const T>(T &,int)' being compiled
|
|---|
| 196 | 1> with
|
|---|
| 197 | 1> [
|
|---|
| 198 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 199 | 1> T=B
|
|---|
| 200 | 1> ]
|
|---|
| 201 | 1> C:\dev\boost-trunk\boost/archive/basic_binary_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::array::oarchive<Archive>::save_override<T>(const T &,unsigned int)' being compiled
|
|---|
| 202 | 1> with
|
|---|
| 203 | 1> [
|
|---|
| 204 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 205 | 1> T=B
|
|---|
| 206 | 1> ]
|
|---|
| 207 | 1> C:\dev\boost-trunk\boost/archive/binary_oarchive_impl.hpp(45) : see reference to function template instantiation 'void boost::archive::basic_binary_oarchive<Archive>::save_override<T>(const T &,int)' being compiled
|
|---|
| 208 | 1> with
|
|---|
| 209 | 1> [
|
|---|
| 210 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 211 | 1> T=B
|
|---|
| 212 | 1> ]
|
|---|
| 213 | 1> C:\dev\boost-trunk\boost/archive/detail/interface_oarchive.hpp(63) : see reference to function template instantiation 'void boost::archive::binary_oarchive_impl<Archive,Elem,Tr>::save_override<T>(T &,int)' being compiled
|
|---|
| 214 | 1> with
|
|---|
| 215 | 1> [
|
|---|
| 216 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 217 | 1> Elem=char,
|
|---|
| 218 | 1> Tr=std::char_traits<char>,
|
|---|
| 219 | 1> T=B
|
|---|
| 220 | 1> ]
|
|---|
| 221 | 1> .\serialization_fun.cpp(35) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<B>(T &)' being compiled
|
|---|
| 222 | 1> with
|
|---|
| 223 | 1> [
|
|---|
| 224 | 1> Archive=boost::archive::binary_oarchive,
|
|---|
| 225 | 1> T=B
|
|---|
| 226 | 1> ]
|
|---|
| 227 | 1>Build log was saved at "file://c:\dev\work\2k8test\Release\BuildLog.htm"
|
|---|
| 228 | 1>2k8test - 1 error(s), 0 warning(s)
|
|---|
| 229 | ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
|---|
| 230 | */
|
|---|