serialize_ptr_array.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright Sebastian Ramacher, 2007.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_ARRAY_HPP
  6. #define BOOST_PTR_CONTAINER_SERIALIZE_PTR_ARRAY_HPP
  7. #include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
  8. #include <boost/ptr_container/ptr_array.hpp>
  9. namespace boost
  10. {
  11. namespace serialization
  12. {
  13. template<class Archive, class T, std::size_t N, class CloneAllocator>
  14. void save(Archive& ar, const ptr_array<T, N, CloneAllocator>& c, unsigned int /*version*/)
  15. {
  16. ptr_container_detail::save_helper(ar, c);
  17. }
  18. template<class Archive, class T, std::size_t N, class CloneAllocator>
  19. void load(Archive& ar, ptr_array<T, N, CloneAllocator>& c, unsigned int /*version*/)
  20. {
  21. typedef ptr_array<T, N, CloneAllocator> container_type;
  22. typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
  23. for(size_type i = 0u; i != N; ++i)
  24. {
  25. T* p;
  26. ar >> boost::serialization::make_nvp( ptr_container_detail::item(), p );
  27. c.replace(i, p);
  28. }
  29. }
  30. template<class Archive, class T, std::size_t N, class CloneAllocator>
  31. void serialize(Archive& ar, ptr_array<T, N, CloneAllocator>& c, const unsigned int version)
  32. {
  33. split_free(ar, c, version);
  34. }
  35. } // namespace serialization
  36. } // namespace boost
  37. #endif