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 | |
6 | #ifndef BOOST_PTR_CONTAINER_SERIALIZE_PTR_ARRAY_HPP |
7 | #define BOOST_PTR_CONTAINER_SERIALIZE_PTR_ARRAY_HPP |
8 | |
9 | #include <boost/ptr_container/detail/serialize_reversible_cont.hpp> |
10 | #include <boost/ptr_container/ptr_array.hpp> |
11 | |
12 | namespace boost |
13 | { |
14 | |
15 | namespace serialization |
16 | { |
17 | |
18 | template<class Archive, class T, std::size_t N, class CloneAllocator> |
19 | void save(Archive& ar, const ptr_array<T, N, CloneAllocator>& c, unsigned int /*version*/) |
20 | { |
21 | ptr_container_detail::save_helper(ar, c); |
22 | } |
23 | |
24 | template<class Archive, class T, std::size_t N, class CloneAllocator> |
25 | void load(Archive& ar, ptr_array<T, N, CloneAllocator>& c, unsigned int /*version*/) |
26 | { |
27 | typedef ptr_array<T, N, CloneAllocator> container_type; |
28 | typedef BOOST_DEDUCED_TYPENAME container_type::size_type size_type; |
29 | |
30 | for(size_type i = 0u; i != N; ++i) |
31 | { |
32 | T* p; |
33 | ar >> boost::serialization::make_nvp( ptr_container_detail::item(), p ); |
34 | c.replace(i, p); |
35 | } |
36 | } |
37 | |
38 | template<class Archive, class T, std::size_t N, class CloneAllocator> |
39 | void serialize(Archive& ar, ptr_array<T, N, CloneAllocator>& c, const unsigned int version) |
40 | { |
41 | split_free(ar, c, version); |
42 | } |
43 | |
44 | } // namespace serialization |
45 | } // namespace boost |
46 | |
47 | #endif |
48 | |