/
dynamic_bitset.hpp
46 lines (37 loc) · 1.23 KB
/
dynamic_bitset.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
46
// Copyright (c) 2016 Hartmut Kaiser
//
// 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_DYNAMIC_BITSET_HPP
#define HPX_SERIALIZATION_DYNAMIC_BITSET_HPP
#include <hpx/runtime/serialization/serialize.hpp>
#include <hpx/runtime/serialization/vector.hpp>
#include <cstddef>
#include <vector>
#include <boost/dynamic_bitset.hpp>
namespace hpx { namespace serialization
{
template <typename Block, typename Alloc>
void serialize(output_archive& ar,
boost::dynamic_bitset<Block, Alloc> const& bs, unsigned)
{
std::size_t num_bits = bs.size();
std::vector<Block> blocks(bs.num_blocks());
boost::to_block_range(bs, blocks.begin());
ar << num_bits;
ar << blocks;
}
template <typename Block, typename Alloc>
void serialize(input_archive& ar,
boost::dynamic_bitset<Block, Alloc>& bs, unsigned)
{
std::size_t num_bits;
std::vector<Block> blocks;
ar >> num_bits;
ar >> blocks;
bs.resize(num_bits);
boost::from_block_range(blocks.begin(), blocks.end(), bs);
bs.resize(num_bits);
}
}}
#endif