]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/serialization/collections_load_imp.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / serialization / collections_load_imp.hpp
1 #ifndef BOOST_SERIALIZATION_COLLECTIONS_LOAD_IMP_HPP
2 #define BOOST_SERIALIZATION_COLLECTIONS_LOAD_IMP_HPP
3
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8
9 #if defined(_MSC_VER) && (_MSC_VER <= 1020)
10 # pragma warning (disable : 4786) // too long name, harmless warning
11 #endif
12
13 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
14 // collections_load_imp.hpp: serialization for loading stl collections
15
16 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
17 // Use, modification and distribution is subject to the Boost Software
18 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
19 // http://www.boost.org/LICENSE_1_0.txt)
20
21 // See http://www.boost.org for updates, documentation, and revision history.
22
23 // helper function templates for serialization of collections
24
25 #include <boost/assert.hpp>
26 #include <cstddef> // size_t
27 #include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
28 #if defined(BOOST_NO_STDC_NAMESPACE)
29 namespace std{
30 using ::size_t;
31 } // namespace std
32 #endif
33 #include <boost/detail/workaround.hpp>
34
35 #include <boost/archive/detail/basic_iarchive.hpp>
36 #include <boost/serialization/access.hpp>
37 #include <boost/serialization/nvp.hpp>
38 #include <boost/serialization/detail/stack_constructor.hpp>
39 #include <boost/serialization/collection_size_type.hpp>
40 #include <boost/serialization/item_version_type.hpp>
41 #include <boost/serialization/detail/is_default_constructible.hpp>
42 #include <boost/utility/enable_if.hpp>
43 #include <boost/move/utility_core.hpp>
44
45 namespace boost{
46 namespace serialization {
47 namespace stl {
48
49 //////////////////////////////////////////////////////////////////////
50 // implementation of serialization for STL containers
51 //
52
53 template<
54 class Archive,
55 class T
56 >
57 typename boost::enable_if<
58 typename detail::is_default_constructible<
59 typename T::value_type
60 >,
61 void
62 >::type
63 collection_load_impl(
64 Archive & ar,
65 T & t,
66 collection_size_type count,
67 item_version_type /*item_version*/
68 ){
69 t.resize(count);
70 typename T::iterator hint;
71 hint = t.begin();
72 while(count-- > 0){
73 ar >> boost::serialization::make_nvp("item", *hint++);
74 }
75 }
76
77 template<
78 class Archive,
79 class T
80 >
81 typename boost::disable_if<
82 typename detail::is_default_constructible<
83 typename T::value_type
84 >,
85 void
86 >::type
87 collection_load_impl(
88 Archive & ar,
89 T & t,
90 collection_size_type count,
91 item_version_type item_version
92 ){
93 t.clear();
94 while(count-- > 0){
95 detail::stack_construct<Archive, typename T::value_type> u(ar, item_version);
96 ar >> boost::serialization::make_nvp("item", u.reference());
97 t.push_back(boost::move(u.reference()));
98 ar.reset_object_address(& t.back() , & u.reference());
99 }
100 }
101
102 } // namespace stl
103 } // namespace serialization
104 } // namespace boost
105
106 #endif //BOOST_SERIALIZATION_COLLECTIONS_LOAD_IMP_HPP