summaryrefslogtreecommitdiff
path: root/boost/dynamic_bitset
diff options
context:
space:
mode:
Diffstat (limited to 'boost/dynamic_bitset')
-rw-r--r--boost/dynamic_bitset/dynamic_bitset.hpp4
-rw-r--r--boost/dynamic_bitset/serialization.hpp46
2 files changed, 50 insertions, 0 deletions
diff --git a/boost/dynamic_bitset/dynamic_bitset.hpp b/boost/dynamic_bitset/dynamic_bitset.hpp
index 86b5428597..05798b5262 100644
--- a/boost/dynamic_bitset/dynamic_bitset.hpp
+++ b/boost/dynamic_bitset/dynamic_bitset.hpp
@@ -348,6 +348,10 @@ public:
#endif
+public:
+ // forward declaration for optional zero-copy serialization support
+ class serialize_impl;
+ friend class serialize_impl;
private:
BOOST_STATIC_CONSTANT(block_width_type, ulong_width = std::numeric_limits<unsigned long>::digits);
diff --git a/boost/dynamic_bitset/serialization.hpp b/boost/dynamic_bitset/serialization.hpp
new file mode 100644
index 0000000000..2b59d56b02
--- /dev/null
+++ b/boost/dynamic_bitset/serialization.hpp
@@ -0,0 +1,46 @@
+// -----------------------------------------------------------
+//
+// Copyright (c) 2015 Seth Heeren
+//
+// 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 BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
+#define BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
+
+#include "boost/dynamic_bitset/dynamic_bitset.hpp"
+#include <boost/serialization/vector.hpp>
+
+namespace boost {
+
+ // implementation for optional zero-copy serialization support
+ template <typename Block, typename Allocator>
+ class dynamic_bitset<Block, Allocator>::serialize_impl
+ {
+ public:
+ template <typename Ar>
+ static void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned) {
+ ar & serialization::make_nvp("m_num_bits", bs.m_num_bits)
+ & serialization::make_nvp("m_bits", bs.m_bits);
+ }
+ };
+
+}
+
+// ADL hook to Boost Serialization library
+namespace boost {
+ namespace serialization {
+
+ template <typename Ar, typename Block, typename Allocator>
+ void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned version) {
+ dynamic_bitset<Block, Allocator>::serialize_impl::serialize(ar, bs, version);
+ }
+
+ } // namespace serialization
+} // namespace boost
+
+#endif // include guard
+