serialization.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/core/nvp.hpp"
  13. #include "boost/dynamic_bitset/dynamic_bitset.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
  22. serialize( Ar & ar, dynamic_bitset< Block, Allocator > & bs, unsigned )
  23. {
  24. ar & boost::make_nvp( "m_num_bits", bs.m_num_bits )
  25. & boost::make_nvp( "m_bits", bs.m_bits );
  26. }
  27. };
  28. }
  29. // ADL hook to Boost Serialization library
  30. namespace boost {
  31. namespace serialization {
  32. template< typename Ar, typename Block, typename Allocator >
  33. void
  34. serialize( Ar & ar, dynamic_bitset< Block, Allocator > & bs, unsigned version )
  35. {
  36. dynamic_bitset< Block, Allocator >::serialize_impl::serialize( ar, bs, version );
  37. }
  38. } // namespace serialization
  39. } // namespace boost
  40. #endif // include guard