serialize_ptr_vector.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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_VECTOR_HPP
  6. #define BOOST_PTR_CONTAINER_SERIALIZE_PTR_VECTOR_HPP
  7. #include <boost/ptr_container/detail/serialize_reversible_cont.hpp>
  8. #include <boost/ptr_container/ptr_vector.hpp>
  9. namespace boost
  10. {
  11. namespace serialization
  12. {
  13. template<class Archive, class T, class CloneAllocator, class Allocator>
  14. void load(Archive& ar, ptr_vector<T, CloneAllocator, Allocator>& c, unsigned int /*version*/)
  15. {
  16. typedef ptr_vector<T, CloneAllocator, Allocator> container_type;
  17. typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type;
  18. size_type n;
  19. ar >> boost::serialization::make_nvp( ptr_container_detail::count(), n );
  20. c.reserve(n);
  21. ptr_container_detail::load_helper(ar, c, n);
  22. }
  23. template<class Archive, class T, class CloneAllocator, class Allocator>
  24. void serialize(Archive& ar, ptr_vector<T, CloneAllocator, Allocator>& c, const unsigned int version)
  25. {
  26. split_free(ar, c, version);
  27. }
  28. } // namespace serialization
  29. } // namespace boost
  30. #endif