Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/serialization/variant.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_VARIANT_HPP | 1 #ifndef BOOST_SERIALIZATION_VARIANT_HPP |
2 #define BOOST_SERIALIZATION_VARIANT_HPP | 2 #define BOOST_SERIALIZATION_VARIANT_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 | |
8 | |
9 #if defined(_MSC_VER) && (_MSC_VER <= 1020) | |
10 # pragma warning (disable : 4786) // too long name, harmless warning | |
11 #endif | 7 #endif |
12 | 8 |
13 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 | 9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
14 // variant.hpp - non-intrusive serialization of variant types | 10 // variant.hpp - non-intrusive serialization of variant types |
15 // | 11 // |
68 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const & v, | 64 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const & v, |
69 unsigned int /*version*/ | 65 unsigned int /*version*/ |
70 ){ | 66 ){ |
71 int which = v.which(); | 67 int which = v.which(); |
72 ar << BOOST_SERIALIZATION_NVP(which); | 68 ar << BOOST_SERIALIZATION_NVP(which); |
73 typedef BOOST_DEDUCED_TYPENAME boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types; | 69 typedef typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types; |
74 variant_save_visitor<Archive> visitor(ar); | 70 variant_save_visitor<Archive> visitor(ar); |
75 v.apply_visitor(visitor); | 71 v.apply_visitor(visitor); |
76 } | 72 } |
77 | 73 |
78 template<class S> | 74 template<class S> |
99 if(which == 0){ | 95 if(which == 0){ |
100 // note: A non-intrusive implementation (such as this one) | 96 // note: A non-intrusive implementation (such as this one) |
101 // necessary has to copy the value. This wouldn't be necessary | 97 // necessary has to copy the value. This wouldn't be necessary |
102 // with an implementation that de-serialized to the address of the | 98 // with an implementation that de-serialized to the address of the |
103 // aligned storage included in the variant. | 99 // aligned storage included in the variant. |
104 typedef BOOST_DEDUCED_TYPENAME mpl::front<S>::type head_type; | 100 typedef typename mpl::front<S>::type head_type; |
105 head_type value; | 101 head_type value; |
106 ar >> BOOST_SERIALIZATION_NVP(value); | 102 ar >> BOOST_SERIALIZATION_NVP(value); |
107 v = value; | 103 v = value; |
108 ar.reset_object_address(& boost::get<head_type>(v), & value); | 104 ar.reset_object_address(& boost::get<head_type>(v), & value); |
109 return; | 105 return; |
110 } | 106 } |
111 typedef BOOST_DEDUCED_TYPENAME mpl::pop_front<S>::type type; | 107 typedef typename mpl::pop_front<S>::type type; |
112 variant_impl<type>::load(ar, which - 1, v, version); | 108 variant_impl<type>::load(ar, which - 1, v, version); |
113 } | 109 } |
114 }; | 110 }; |
115 | 111 |
116 template<class Archive, class V> | 112 template<class Archive, class V> |
118 Archive & ar, | 114 Archive & ar, |
119 int which, | 115 int which, |
120 V & v, | 116 V & v, |
121 const unsigned int version | 117 const unsigned int version |
122 ){ | 118 ){ |
123 typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<mpl::empty<S>, | 119 typedef typename mpl::eval_if<mpl::empty<S>, |
124 mpl::identity<load_null>, | 120 mpl::identity<load_null>, |
125 mpl::identity<load_impl> | 121 mpl::identity<load_impl> |
126 >::type typex; | 122 >::type typex; |
127 typex::invoke(ar, which, v, version); | 123 typex::invoke(ar, which, v, version); |
128 } | 124 } |
134 Archive & ar, | 130 Archive & ar, |
135 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>& v, | 131 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>& v, |
136 const unsigned int version | 132 const unsigned int version |
137 ){ | 133 ){ |
138 int which; | 134 int which; |
139 typedef BOOST_DEDUCED_TYPENAME boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types; | 135 typedef typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types; |
140 ar >> BOOST_SERIALIZATION_NVP(which); | 136 ar >> BOOST_SERIALIZATION_NVP(which); |
141 if(which >= mpl::size<types>::value) | 137 if(which >= mpl::size<types>::value) |
142 // this might happen if a type was removed from the list of variant types | 138 // this might happen if a type was removed from the list of variant types |
143 boost::serialization::throw_exception( | 139 boost::serialization::throw_exception( |
144 boost::archive::archive_exception( | 140 boost::archive::archive_exception( |