serialization.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // -----------------------------------------------------------
  2. //
  3. // Copyright (c) 2015 Seth Heeren
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // -----------------------------------------------------------
  10. #ifndef BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
  11. #define BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
  12. #include "boost/dynamic_bitset/dynamic_bitset.hpp"
  13. #include <boost/core/nvp.hpp>
  14. namespace boost {
  15. // implementation for optional zero-copy serialization support
  16. template <typename Block, typename Allocator>
  17. class dynamic_bitset<Block, Allocator>::serialize_impl
  18. {
  19. public:
  20. template <typename Ar>
  21. static void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned) {
  22. ar & boost::make_nvp("m_num_bits", bs.m_num_bits)
  23. & boost::make_nvp("m_bits", bs.m_bits);
  24. }
  25. };
  26. }
  27. // ADL hook to Boost Serialization library
  28. namespace boost {
  29. namespace serialization {
  30. template <typename Ar, typename Block, typename Allocator>
  31. void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned version) {
  32. dynamic_bitset<Block, Allocator>::serialize_impl::serialize(ar, bs, version);
  33. }
  34. } // namespace serialization
  35. } // namespace boost
  36. #endif // include guard