untracked_pair.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include <boost/mpi/datatype.hpp>
  12. #include <utility> // for std::pair
  13. #include <boost/serialization/utility.hpp>
  14. namespace boost { namespace parallel { namespace detail {
  15. /**
  16. * This structure is like std::pair, with the only difference
  17. * that tracking in the serialization library is turned off.
  18. */
  19. template<typename T, typename U>
  20. struct untracked_pair : public std::pair<T,U>
  21. {
  22. untracked_pair() {}
  23. untracked_pair(const T& t, const U& u)
  24. : std::pair<T,U>(t,u) {}
  25. template<class T1, class U1>
  26. untracked_pair(std::pair<T1,U1> const& p)
  27. : std::pair<T,U>(p) {}
  28. };
  29. template<typename T, typename U>
  30. inline untracked_pair<T, U>
  31. make_untracked_pair(const T& t, const U& u)
  32. {
  33. return untracked_pair<T,U>(t,u);
  34. }
  35. } } } // end namespace boost::parallel::detail
  36. namespace boost { namespace mpi {
  37. template<typename T, typename U>
  38. struct is_mpi_datatype<boost::parallel::detail::untracked_pair<T, U> >
  39. : is_mpi_datatype<std::pair<T,U> > {};
  40. } } // end namespace boost::mpi
  41. namespace boost { namespace serialization {
  42. // pair
  43. template<class Archive, class F, class S>
  44. inline void serialize(
  45. Archive & ar,
  46. boost::parallel::detail::untracked_pair<F, S> & p,
  47. const unsigned int /* file_version */
  48. ){
  49. ar & boost::serialization::make_nvp("first", p.first);
  50. ar & boost::serialization::make_nvp("second", p.second);
  51. }
  52. template<typename T, typename U>
  53. struct is_bitwise_serializable<
  54. boost::parallel::detail::untracked_pair<T, U> >
  55. : is_bitwise_serializable<std::pair<T, U> > {};
  56. template<typename T, typename U>
  57. struct implementation_level<boost::parallel::detail::untracked_pair<T, U> >
  58. : mpl::int_<object_serializable> {} ;
  59. template<typename T, typename U>
  60. struct tracking_level<boost::parallel::detail::untracked_pair<T, U> >
  61. : mpl::int_<track_never> {} ;
  62. } } // end namespace boost::serialization
  63. #endif // BOOST_PARALLEL_DETAIL_UNTRACKED_PAIR_HPP