unordered_map.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #ifndef BOOST_SERIALIZATION_UNORDERED_MAP_HPP
  2. #define BOOST_SERIALIZATION_UNORDERED_MAP_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. // serialization/unordered_map.hpp:
  9. // serialization for stl unordered_map templates
  10. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  11. // (C) Copyright 2014 Jim Bell
  12. // Use, modification and distribution is subject to the Boost Software
  13. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. // See http://www.boost.org for updates, documentation, and revision history.
  16. #include <boost/config.hpp>
  17. #include <unordered_map>
  18. #include <boost/serialization/utility.hpp>
  19. #include <boost/serialization/unordered_collections_save_imp.hpp>
  20. #include <boost/serialization/unordered_collections_load_imp.hpp>
  21. #include <boost/serialization/archive_input_unordered_map.hpp>
  22. #include <boost/serialization/split_free.hpp>
  23. namespace boost {
  24. namespace serialization {
  25. template<
  26. class Archive,
  27. class Key,
  28. class T,
  29. class HashFcn,
  30. class EqualKey,
  31. class Allocator
  32. >
  33. inline void save(
  34. Archive & ar,
  35. const std::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
  36. const unsigned int /*file_version*/
  37. ){
  38. boost::serialization::stl::save_unordered_collection<
  39. Archive,
  40. std::unordered_map<Key, T, HashFcn, EqualKey, Allocator>
  41. >(ar, t);
  42. }
  43. template<
  44. class Archive,
  45. class Key,
  46. class T,
  47. class HashFcn,
  48. class EqualKey,
  49. class Allocator
  50. >
  51. inline void load(
  52. Archive & ar,
  53. std::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
  54. const unsigned int /*file_version*/
  55. ){
  56. boost::serialization::stl::load_unordered_collection<
  57. Archive,
  58. std::unordered_map<Key, T, HashFcn, EqualKey, Allocator>,
  59. boost::serialization::stl::archive_input_unordered_map<
  60. Archive,
  61. std::unordered_map<Key, T, HashFcn, EqualKey, Allocator>
  62. >
  63. >(ar, t);
  64. }
  65. // split non-intrusive serialization function member into separate
  66. // non intrusive save/load member functions
  67. template<
  68. class Archive,
  69. class Key,
  70. class T,
  71. class HashFcn,
  72. class EqualKey,
  73. class Allocator
  74. >
  75. inline void serialize(
  76. Archive & ar,
  77. std::unordered_map<Key, T, HashFcn, EqualKey, Allocator> &t,
  78. const unsigned int file_version
  79. ){
  80. boost::serialization::split_free(ar, t, file_version);
  81. }
  82. // unordered_multimap
  83. template<
  84. class Archive,
  85. class Key,
  86. class T,
  87. class HashFcn,
  88. class EqualKey,
  89. class Allocator
  90. >
  91. inline void save(
  92. Archive & ar,
  93. const std::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator> &t,
  94. const unsigned int /*file_version*/
  95. ){
  96. boost::serialization::stl::save_unordered_collection<
  97. Archive,
  98. std::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>
  99. >(ar, t);
  100. }
  101. template<
  102. class Archive,
  103. class Key,
  104. class T,
  105. class HashFcn,
  106. class EqualKey,
  107. class Allocator
  108. >
  109. inline void load(
  110. Archive & ar,
  111. std::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator> &t,
  112. const unsigned int /*file_version*/
  113. ){
  114. boost::serialization::stl::load_unordered_collection<
  115. Archive,
  116. std::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>,
  117. boost::serialization::stl::archive_input_unordered_multimap<
  118. Archive,
  119. std::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator>
  120. >
  121. >(ar, t);
  122. }
  123. // split non-intrusive serialization function member into separate
  124. // non intrusive save/load member functions
  125. template<
  126. class Archive,
  127. class Key,
  128. class T,
  129. class HashFcn,
  130. class EqualKey,
  131. class Allocator
  132. >
  133. inline void serialize(
  134. Archive & ar,
  135. std::unordered_multimap<Key, T, HashFcn, EqualKey, Allocator> &t,
  136. const unsigned int file_version
  137. ){
  138. boost::serialization::split_free(ar, t, file_version);
  139. }
  140. } // namespace serialization
  141. } // namespace boost
  142. #endif // BOOST_SERIALIZATION_UNORDERED_MAP_HPP