unordered_set.hpp 4.0 KB

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