priority_queue.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef BOOST_SERIALIZATION_PRIORITY_QUEUE_HPP
  2. #define BOOST_SERIALIZATION_PRIORITY_QUEUE_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // priority_queue.hpp
  9. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  10. // Use, modification and distribution is subject to the Boost Software
  11. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. // See http://www.boost.org for updates, documentation, and revision history.
  14. #include <queue>
  15. #include <boost/config.hpp>
  16. #include <boost/mpl/eval_if.hpp>
  17. #include <boost/mpl/identity.hpp>
  18. // function specializations must be defined in the appropriate
  19. // namespace - boost::serialization
  20. #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
  21. #define STD _STLP_STD
  22. #else
  23. #define STD std
  24. #endif
  25. namespace boost {
  26. namespace serialization {
  27. namespace detail{
  28. template <typename U, typename Container, typename Compare>
  29. struct priority_queue_save : public STD::priority_queue<U, Container, Compare> {
  30. template<class Archive>
  31. void operator()(Archive & ar, const unsigned int file_version) const {
  32. save(ar, STD::priority_queue<U, Container, Compare>::c, file_version);
  33. }
  34. };
  35. template <typename U, typename Container, typename Compare>
  36. struct priority_queue_load : public STD::priority_queue<U, Container, Compare> {
  37. template<class Archive>
  38. void operator()(Archive & ar, const unsigned int file_version) {
  39. load(ar, STD::priority_queue<U, Container, Compare>::c, file_version);
  40. }
  41. };
  42. } // detail
  43. template<class Archive, class T, class Container, class Compare>
  44. inline void serialize(
  45. Archive & ar,
  46. std::priority_queue< T, Container, Compare> & t,
  47. const unsigned int file_version
  48. ){
  49. typedef typename mpl::eval_if<
  50. typename Archive::is_saving,
  51. mpl::identity<detail::priority_queue_save<T, Container, Compare> >,
  52. mpl::identity<detail::priority_queue_load<T, Container, Compare> >
  53. >::type typex;
  54. static_cast<typex &>(t)(ar, file_version);
  55. }
  56. } // namespace serialization
  57. } // namespace boost
  58. #include <boost/serialization/collection_traits.hpp>
  59. BOOST_SERIALIZATION_COLLECTION_TRAITS(STD::priority_queue)
  60. #undef STD
  61. #endif // BOOST_SERIALIZATION_PRIORITY_QUEUE_HPP