/
list.hpp
45 lines (37 loc) · 1.09 KB
/
list.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2015 Thomas Heller
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef HPX_SERIALIZATION_LIST_HPP
#define HPX_SERIALIZATION_LIST_HPP
#include <hpx/runtime/serialization/serialize.hpp>
#include <list>
namespace hpx { namespace serialization
{
template <typename T, typename Allocator>
void serialize(input_archive & ar, std::list<T, Allocator> & ls, unsigned)
{
// normal load ...
typedef typename std::list<T, Allocator>::size_type size_type;
size_type size;
ar >> size; //-V128
if(size == 0) return;
ls.resize(size);
for(auto & li: ls)
{
ar >> li;
}
}
template <typename T, typename Allocator>
void serialize(output_archive & ar, const std::list<T, Allocator> & ls, unsigned)
{
// normal save ...
ar << ls.size(); //-V128
if(ls.empty()) return;
for(auto const & li: ls)
{
ar << li;
}
}
}}
#endif