/
set.hpp
43 lines (36 loc) · 1.09 KB
/
set.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
// Copyright (c) 2015 Andreas Schaefer
//
// 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_SET_HPP
#define HPX_SERIALIZATION_SET_HPP
#include <hpx/config.hpp>
#include <hpx/runtime/serialization/serialize.hpp>
#include <set>
namespace hpx { namespace serialization
{
template <class T, class Compare, class Allocator>
void serialize(input_archive & ar, std::set<T, Compare, Allocator> & set, unsigned)
{
set.clear();
boost::uint64_t size;
ar >> size;
for (std::size_t i = 0; i < size; ++i) {
T t;
ar >> t;
set.insert(set.end(), std::move(t));
}
}
template <class T, class Compare, class Allocator>
void serialize(output_archive & ar,const std::set<T, Compare, Allocator> & set,
unsigned)
{
boost::uint64_t size = set.size();
ar << size;
if(set.empty()) return;
for (T const& i: set) {
ar << i;
}
}
}}
#endif