Chris@16
|
1 #ifndef BOOST_SERIALIZATION_UTILITY_HPP
|
Chris@16
|
2 #define BOOST_SERIALIZATION_UTILITY_HPP
|
Chris@16
|
3
|
Chris@16
|
4 // MS compatible compilers support #pragma once
|
Chris@101
|
5 #if defined(_MSC_VER)
|
Chris@16
|
6 # pragma once
|
Chris@16
|
7 #endif
|
Chris@16
|
8
|
Chris@16
|
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
Chris@16
|
10 // serialization/utility.hpp:
|
Chris@16
|
11 // serialization for stl utility templates
|
Chris@16
|
12
|
Chris@16
|
13 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
Chris@16
|
14 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
15 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
16 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
17
|
Chris@16
|
18 // See http://www.boost.org for updates, documentation, and revision history.
|
Chris@16
|
19
|
Chris@16
|
20 #include <utility>
|
Chris@16
|
21 #include <boost/config.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/type_traits/remove_const.hpp>
|
Chris@16
|
24 #include <boost/serialization/nvp.hpp>
|
Chris@16
|
25 #include <boost/serialization/is_bitwise_serializable.hpp>
|
Chris@16
|
26 #include <boost/mpl/and.hpp>
|
Chris@16
|
27
|
Chris@16
|
28 namespace boost {
|
Chris@16
|
29 namespace serialization {
|
Chris@16
|
30
|
Chris@16
|
31 // pair
|
Chris@16
|
32 template<class Archive, class F, class S>
|
Chris@16
|
33 inline void serialize(
|
Chris@16
|
34 Archive & ar,
|
Chris@16
|
35 std::pair<F, S> & p,
|
Chris@16
|
36 const unsigned int /* file_version */
|
Chris@16
|
37 ){
|
Chris@16
|
38 // note: we remove any const-ness on the first argument. The reason is that
|
Chris@16
|
39 // for stl maps, the type saved is pair<const key, T). We remove
|
Chris@16
|
40 // the const-ness in order to be able to load it.
|
Chris@101
|
41 typedef typename boost::remove_const<F>::type typef;
|
Chris@16
|
42 ar & boost::serialization::make_nvp("first", const_cast<typef &>(p.first));
|
Chris@16
|
43 ar & boost::serialization::make_nvp("second", p.second);
|
Chris@16
|
44 }
|
Chris@16
|
45
|
Chris@16
|
46 /// specialization of is_bitwise_serializable for pairs
|
Chris@16
|
47 template <class T, class U>
|
Chris@16
|
48 struct is_bitwise_serializable<std::pair<T,U> >
|
Chris@16
|
49 : public mpl::and_<is_bitwise_serializable< T >,is_bitwise_serializable<U> >
|
Chris@16
|
50 {
|
Chris@16
|
51 };
|
Chris@16
|
52
|
Chris@16
|
53 } // serialization
|
Chris@16
|
54 } // namespace boost
|
Chris@16
|
55
|
Chris@16
|
56 #endif // BOOST_SERIALIZATION_UTILITY_HPP
|