1 /* Copyright 2003-2013 Joaquin M Lopez Munoz.
2  * Distributed under the Boost Software License, Version 1.0.
3  * (See accompanying file LICENSE_1_0.txt or copy at
4  * http://www.boost.org/LICENSE_1_0.txt)
5  *
6  * See http://www.boost.org/libs/multi_index for library home page.
7  */
8 
9 #ifndef BOOST_MULTI_INDEX_DETAIL_SERIALIZATION_VERSION_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_SERIALIZATION_VERSION_HPP
11 
12 #if defined(_MSC_VER)
13 #pragma once
14 #endif
15 
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17 #include <boost/serialization/split_member.hpp>
18 #include <boost/serialization/version.hpp>
19 
20 namespace boost{
21 
22 namespace multi_index{
23 
24 namespace detail{
25 
26 /* Helper class for storing and retrieving a given type serialization class
27  * version while avoiding saving the number multiple times in the same
28  * archive.
29  * Behavior undefined if template partial specialization is not supported.
30  */
31 
32 template<typename T>
33 struct serialization_version
34 {
serialization_versionboost::multi_index::detail::serialization_version35   serialization_version():
36     value(boost::serialization::version<serialization_version>::value){}
37 
operator =boost::multi_index::detail::serialization_version38   serialization_version& operator=(unsigned int x){value=x;return *this;};
39 
operator unsigned intboost::multi_index::detail::serialization_version40   operator unsigned int()const{return value;}
41 
42 private:
43   friend class boost::serialization::access;
44 
BOOST_SERIALIZATION_SPLIT_MEMBERboost::multi_index::detail::serialization_version45   BOOST_SERIALIZATION_SPLIT_MEMBER()
46 
47   template<class Archive>
48   void save(Archive&,const unsigned int)const{}
49 
50   template<class Archive>
loadboost::multi_index::detail::serialization_version51   void load(Archive&,const unsigned int version)
52   {
53     this->value=version;
54   }
55 
56   unsigned int value;
57 };
58 
59 } /* namespace multi_index::detail */
60 
61 } /* namespace multi_index */
62 
63 namespace serialization {
64 template<typename T>
65 struct version<boost::multi_index::detail::serialization_version<T> >
66 {
67   BOOST_STATIC_CONSTANT(int,value=version<T>::value);
68 };
69 } /* namespace serialization */
70 
71 } /* namespace boost */
72 
73 #endif
74