File indexing completed on 2025-01-18 09:50:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_PROPERTY_MAP_UNSAFE_SERIALIZE_HPP
0014 #define BOOST_PROPERTY_MAP_UNSAFE_SERIALIZE_HPP
0015
0016 #include <boost/mpi/datatype.hpp>
0017 #include <boost/serialization/is_bitwise_serializable.hpp>
0018 #include <boost/mpl/bool.hpp>
0019 #include <boost/mpl/if.hpp>
0020 #include <boost/cstdint.hpp>
0021 #include <boost/static_assert.hpp>
0022 #include <boost/type_traits.hpp>
0023 #include <utility>
0024
0025 BOOST_IS_BITWISE_SERIALIZABLE(void*)
0026 namespace boost { namespace mpi {
0027 template<> struct is_mpi_datatype<void*> : mpl::true_ { };
0028 } }
0029
0030 namespace boost {
0031 typedef mpl::if_c<(sizeof(int) == sizeof(void*)),
0032 int,
0033 mpl::if_c<(sizeof(long) == sizeof(void*)),
0034 long,
0035 mpl::if_c<(sizeof(void*) <= sizeof(boost::intmax_t)),
0036 boost::intmax_t,
0037 void>::type
0038 >::type
0039 >::type ptr_serialize_type;
0040
0041 BOOST_STATIC_ASSERT ((!boost::is_void<ptr_serialize_type>::value));
0042
0043 template<typename T> inline T& unsafe_serialize(T& x) { return x; }
0044
0045 inline ptr_serialize_type& unsafe_serialize(void*& x)
0046 { return reinterpret_cast<ptr_serialize_type&>(x); }
0047
0048
0049 namespace mpi {
0050 template<> inline MPI_Datatype get_mpi_datatype<void*>(void* const& x)
0051 {
0052 return get_mpi_datatype<ptr_serialize_type>();
0053 }
0054 }
0055
0056 template<typename T, typename U>
0057 struct unsafe_pair
0058 {
0059 unsafe_pair() { }
0060 unsafe_pair(const T& t, const U& u) : first(t), second(u) { }
0061 unsafe_pair(const std::pair<T, U>& p) : first(p.first), second(p.second) { }
0062 T first;
0063 U second;
0064
0065 template<typename Archiver>
0066 void serialize(Archiver& ar, const unsigned )
0067 {
0068 ar & unsafe_serialize(first) & unsafe_serialize(second);
0069 }
0070 };
0071
0072 template<typename T, typename U>
0073 bool operator<(unsafe_pair<T,U> const& x, unsafe_pair<T,U> const& y)
0074 {
0075 return std::make_pair(x.first, x.second) <
0076 std::make_pair(y.first, y.second);
0077 }
0078
0079 }
0080
0081 #endif