comparison DEPENDENCIES/generic/include/boost/serialization/vector.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
1 #ifndef BOOST_SERIALIZATION_VECTOR_HPP 1 #ifndef BOOST_SERIALIZATION_VECTOR_HPP
2 #define BOOST_SERIALIZATION_VECTOR_HPP 2 #define BOOST_SERIALIZATION_VECTOR_HPP
3 3
4 // MS compatible compilers support #pragma once 4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020) 5 #if defined(_MSC_VER)
6 # pragma once 6 # pragma once
7 #endif 7 #endif
8 8
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // vector.hpp: serialization for stl vector templates 10 // vector.hpp: serialization for stl vector templates
19 19
20 #include <vector> 20 #include <vector>
21 21
22 #include <boost/config.hpp> 22 #include <boost/config.hpp>
23 #include <boost/detail/workaround.hpp> 23 #include <boost/detail/workaround.hpp>
24 #include <boost/type_traits/is_arithmetic.hpp> 24
25 #include <boost/archive/detail/basic_iarchive.hpp>
26 #include <boost/serialization/access.hpp>
27 #include <boost/serialization/nvp.hpp>
28 #include <boost/serialization/collection_size_type.hpp>
29 #include <boost/serialization/item_version_type.hpp>
25 30
26 #include <boost/serialization/collections_save_imp.hpp> 31 #include <boost/serialization/collections_save_imp.hpp>
27 #include <boost/serialization/collections_load_imp.hpp>
28 #include <boost/serialization/split_free.hpp> 32 #include <boost/serialization/split_free.hpp>
29 #include <boost/serialization/array.hpp> 33 #include <boost/serialization/array.hpp>
30 #include <boost/serialization/detail/get_data.hpp> 34 #include <boost/serialization/detail/get_data.hpp>
35 #include <boost/serialization/detail/stack_constructor.hpp>
36 #include <boost/serialization/detail/is_default_constructible.hpp>
31 #include <boost/mpl/bool.hpp> 37 #include <boost/mpl/bool.hpp>
32 38
33 // default is being compatible with version 1.34.1 files, not 1.35 files 39 // default is being compatible with version 1.34.1 files, not 1.35 files
34 #ifndef BOOST_SERIALIZATION_VECTOR_VERSIONED 40 #ifndef BOOST_SERIALIZATION_VECTOR_VERSIONED
35 #define BOOST_SERIALIZATION_VECTOR_VERSIONED(V) (V==4 || V==5) 41 #define BOOST_SERIALIZATION_VECTOR_VERSIONED(V) (V==4 || V==5)
68 Archive & ar, 74 Archive & ar,
69 std::vector<U, Allocator> &t, 75 std::vector<U, Allocator> &t,
70 const unsigned int /* file_version */, 76 const unsigned int /* file_version */,
71 mpl::false_ 77 mpl::false_
72 ){ 78 ){
73 boost::serialization::stl::load_collection< 79 const boost::archive::library_version_type library_version(
74 Archive, 80 ar.get_library_version()
75 std::vector<U, Allocator>, 81 );
76 boost::serialization::stl::archive_input_seq< 82 // retrieve number of elements
77 Archive, STD::vector<U, Allocator> 83 item_version_type item_version(0);
78 >, 84 collection_size_type count;
79 boost::serialization::stl::reserve_imp<STD::vector<U, Allocator> > 85 ar >> BOOST_SERIALIZATION_NVP(count);
80 >(ar, t); 86 if(boost::archive::library_version_type(3) < library_version){
87 ar >> BOOST_SERIALIZATION_NVP(item_version);
88 }
89 if(detail::is_default_constructible<U>()){
90 t.resize(count);
91 typename std::vector<U, Allocator>::iterator hint;
92 hint = t.begin();
93 while(count-- > 0){
94 ar >> boost::serialization::make_nvp("item", *hint++);
95 }
96 }
97 else{
98 t.reserve(count);
99 while(count-- > 0){
100 detail::stack_construct<Archive, U> u(ar, item_version);
101 ar >> boost::serialization::make_nvp("item", u.reference());
102 t.push_back(u.reference());
103 ar.reset_object_address(& t.back() , & u.reference());
104 }
105 }
81 } 106 }
82 107
83 // the optimized versions 108 // the optimized versions
84 109
85 template<class Archive, class U, class Allocator> 110 template<class Archive, class U, class Allocator>
119 inline void save( 144 inline void save(
120 Archive & ar, 145 Archive & ar,
121 const std::vector<U, Allocator> &t, 146 const std::vector<U, Allocator> &t,
122 const unsigned int file_version 147 const unsigned int file_version
123 ){ 148 ){
124 typedef BOOST_DEDUCED_TYPENAME 149 typedef typename
125 boost::serialization::use_array_optimization<Archive>::template apply< 150 boost::serialization::use_array_optimization<Archive>::template apply<
126 BOOST_DEDUCED_TYPENAME remove_const<U>::type 151 typename remove_const<U>::type
127 >::type use_optimized; 152 >::type use_optimized;
128 save(ar,t,file_version, use_optimized()); 153 save(ar,t,file_version, use_optimized());
129 } 154 }
130 155
131 template<class Archive, class U, class Allocator> 156 template<class Archive, class U, class Allocator>
139 { 164 {
140 load(ar,t,file_version, boost::is_arithmetic<U>()); 165 load(ar,t,file_version, boost::is_arithmetic<U>());
141 return; 166 return;
142 } 167 }
143 #endif 168 #endif
144 typedef BOOST_DEDUCED_TYPENAME 169 typedef typename
145 boost::serialization::use_array_optimization<Archive>::template apply< 170 boost::serialization::use_array_optimization<Archive>::template apply<
146 BOOST_DEDUCED_TYPENAME remove_const<U>::type 171 typename remove_const<U>::type
147 >::type use_optimized; 172 >::type use_optimized;
148 load(ar,t,file_version, use_optimized()); 173 load(ar,t,file_version, use_optimized());
149 } 174 }
150 175
151 // split non-intrusive serialization function member into separate 176 // split non-intrusive serialization function member into separate
156 std::vector<U, Allocator> & t, 181 std::vector<U, Allocator> & t,
157 const unsigned int file_version 182 const unsigned int file_version
158 ){ 183 ){
159 boost::serialization::split_free(ar, t, file_version); 184 boost::serialization::split_free(ar, t, file_version);
160 } 185 }
161
162 #if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
163 186
164 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 187 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
165 // vector<bool> 188 // vector<bool>
166 template<class Archive, class Allocator> 189 template<class Archive, class Allocator>
167 inline void save( 190 inline void save(
186 const unsigned int /* file_version */ 209 const unsigned int /* file_version */
187 ){ 210 ){
188 // retrieve number of elements 211 // retrieve number of elements
189 collection_size_type count; 212 collection_size_type count;
190 ar >> BOOST_SERIALIZATION_NVP(count); 213 ar >> BOOST_SERIALIZATION_NVP(count);
191 t.clear(); 214 t.resize(count);
192 while(count-- > 0){ 215 int i;
193 bool i; 216 for(i = 0; i < count; ++i){
194 ar >> boost::serialization::make_nvp("item", i); 217 bool b;
195 t.push_back(i); 218 ar >> boost::serialization::make_nvp("item", b);
219 t[i] = b;
196 } 220 }
197 } 221 }
198 222
199 // split non-intrusive serialization function member into separate 223 // split non-intrusive serialization function member into separate
200 // non intrusive save/load member functions 224 // non intrusive save/load member functions
205 const unsigned int file_version 229 const unsigned int file_version
206 ){ 230 ){
207 boost::serialization::split_free(ar, t, file_version); 231 boost::serialization::split_free(ar, t, file_version);
208 } 232 }
209 233
210 #endif // BOOST_WORKAROUND
211
212 } // serialization 234 } // serialization
213 } // namespace boost 235 } // namespace boost
214 236
215 #include <boost/serialization/collection_traits.hpp> 237 #include <boost/serialization/collection_traits.hpp>
216 238