Chris@102
|
1 // Copyright (C) 2007 Matthias Troyer
|
Chris@102
|
2 //
|
Chris@102
|
3 // Use, modification and distribution is subject to the Boost Software
|
Chris@102
|
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@102
|
5 //
|
Chris@102
|
6 // This file contains helper data structures for use in transmitting
|
Chris@102
|
7 // properties. The basic idea is to optimize away any storage for the
|
Chris@102
|
8 // properties when no properties are specified.
|
Chris@102
|
9 #ifndef BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP
|
Chris@102
|
10 #define BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP
|
Chris@102
|
11
|
Chris@102
|
12 #include <boost/mpi/datatype.hpp>
|
Chris@102
|
13 #include <utility> // for std::pair
|
Chris@102
|
14 #include <boost/serialization/utility.hpp>
|
Chris@102
|
15
|
Chris@102
|
16 namespace boost { namespace parallel { namespace detail {
|
Chris@102
|
17
|
Chris@102
|
18 /**
|
Chris@102
|
19 * This structure is like std::pair, with the only difference
|
Chris@102
|
20 * that tracking in the serialization library is turned off.
|
Chris@102
|
21 */
|
Chris@102
|
22
|
Chris@102
|
23 template<typename T, typename U>
|
Chris@102
|
24 struct untracked_pair : public std::pair<T,U>
|
Chris@102
|
25 {
|
Chris@102
|
26 untracked_pair() {}
|
Chris@102
|
27
|
Chris@102
|
28 untracked_pair(const T& t, const U& u)
|
Chris@102
|
29 : std::pair<T,U>(t,u) {}
|
Chris@102
|
30
|
Chris@102
|
31 template<class T1, class U1>
|
Chris@102
|
32 untracked_pair(std::pair<T1,U1> const& p)
|
Chris@102
|
33 : std::pair<T,U>(p) {}
|
Chris@102
|
34 };
|
Chris@102
|
35
|
Chris@102
|
36 template<typename T, typename U>
|
Chris@102
|
37 inline untracked_pair<T, U>
|
Chris@102
|
38 make_untracked_pair(const T& t, const U& u)
|
Chris@102
|
39 {
|
Chris@102
|
40 return untracked_pair<T,U>(t,u);
|
Chris@102
|
41 }
|
Chris@102
|
42
|
Chris@102
|
43 } } } // end namespace boost::parallel::detail
|
Chris@102
|
44
|
Chris@102
|
45 namespace boost { namespace mpi {
|
Chris@102
|
46
|
Chris@102
|
47 template<typename T, typename U>
|
Chris@102
|
48 struct is_mpi_datatype<boost::parallel::detail::untracked_pair<T, U> >
|
Chris@102
|
49 : is_mpi_datatype<std::pair<T,U> > {};
|
Chris@102
|
50
|
Chris@102
|
51 } } // end namespace boost::mpi
|
Chris@102
|
52
|
Chris@102
|
53 namespace boost { namespace serialization {
|
Chris@102
|
54
|
Chris@102
|
55 // pair
|
Chris@102
|
56 template<class Archive, class F, class S>
|
Chris@102
|
57 inline void serialize(
|
Chris@102
|
58 Archive & ar,
|
Chris@102
|
59 boost::parallel::detail::untracked_pair<F, S> & p,
|
Chris@102
|
60 const unsigned int /* file_version */
|
Chris@102
|
61 ){
|
Chris@102
|
62 ar & boost::serialization::make_nvp("first", p.first);
|
Chris@102
|
63 ar & boost::serialization::make_nvp("second", p.second);
|
Chris@102
|
64 }
|
Chris@102
|
65
|
Chris@102
|
66 template<typename T, typename U>
|
Chris@102
|
67 struct is_bitwise_serializable<
|
Chris@102
|
68 boost::parallel::detail::untracked_pair<T, U> >
|
Chris@102
|
69 : is_bitwise_serializable<std::pair<T, U> > {};
|
Chris@102
|
70
|
Chris@102
|
71 template<typename T, typename U>
|
Chris@102
|
72 struct implementation_level<boost::parallel::detail::untracked_pair<T, U> >
|
Chris@102
|
73 : mpl::int_<object_serializable> {} ;
|
Chris@102
|
74
|
Chris@102
|
75 template<typename T, typename U>
|
Chris@102
|
76 struct tracking_level<boost::parallel::detail::untracked_pair<T, U> >
|
Chris@102
|
77 : mpl::int_<track_never> {} ;
|
Chris@102
|
78
|
Chris@102
|
79 } } // end namespace boost::serialization
|
Chris@102
|
80
|
Chris@102
|
81 #endif // BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP
|