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