]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/serialization/valarray.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / serialization / valarray.hpp
1 #ifndef BOOST_SERIALIZATION_VALARAY_HPP
2 #define BOOST_SERIALIZATION_VALARAY_HPP
3
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // valarray.hpp: serialization for stl vector templates
11
12 // (C) Copyright 2005 Matthias Troyer .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
16
17 // See http://www.boost.org for updates, documentation, and revision history.
18
19 #include <valarray>
20 #include <boost/config.hpp>
21 #include <boost/core/addressof.hpp>
22
23 #include <boost/serialization/collections_save_imp.hpp>
24 #include <boost/serialization/collections_load_imp.hpp>
25 #include <boost/serialization/split_free.hpp>
26 #include <boost/serialization/collection_size_type.hpp>
27 #include <boost/serialization/array_wrapper.hpp>
28
29 // function specializations must be defined in the appropriate
30 // namespace - boost::serialization
31 #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
32 #define STD _STLP_STD
33 #else
34 #define STD std
35 #endif
36
37 namespace boost {
38 namespace serialization {
39
40 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
41 // valarray< T >
42
43 template<class Archive, class U>
44 void save( Archive & ar, const STD::valarray<U> &t, const unsigned int /*file_version*/ )
45 {
46 const collection_size_type count(t.size());
47 ar << BOOST_SERIALIZATION_NVP(count);
48 if (t.size()){
49 // explict template arguments to pass intel C++ compiler
50 ar << serialization::make_array<const U, collection_size_type>(
51 static_cast<const U *>( boost::addressof(t[0]) ),
52 count
53 );
54 }
55 }
56
57 template<class Archive, class U>
58 void load( Archive & ar, STD::valarray<U> &t, const unsigned int /*file_version*/ )
59 {
60 collection_size_type count;
61 ar >> BOOST_SERIALIZATION_NVP(count);
62 t.resize(count);
63 if (t.size()){
64 // explict template arguments to pass intel C++ compiler
65 ar >> serialization::make_array<U, collection_size_type>(
66 static_cast<U *>( boost::addressof(t[0]) ),
67 count
68 );
69 }
70 }
71
72 // split non-intrusive serialization function member into separate
73 // non intrusive save/load member functions
74 template<class Archive, class U>
75 inline void serialize( Archive & ar, STD::valarray<U> & t, const unsigned int file_version)
76 {
77 boost::serialization::split_free(ar, t, file_version);
78 }
79
80 } } // end namespace boost::serialization
81
82 #include <boost/serialization/collection_traits.hpp>
83
84 BOOST_SERIALIZATION_COLLECTION_TRAITS(STD::valarray)
85 #undef STD
86
87 #endif // BOOST_SERIALIZATION_VALARAY_HPP