summaryrefslogtreecommitdiff
path: root/boost/serialization/bitset.hpp
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-10-30 12:57:26 -0700
committerAnas Nashif <anas.nashif@intel.com>2012-10-30 12:57:26 -0700
commit1a78a62555be32868418fe52f8e330c9d0f95d5a (patch)
treed3765a80e7d3b9640ec2e930743630cd6b9fce2b /boost/serialization/bitset.hpp
downloadboost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz
boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2
boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'boost/serialization/bitset.hpp')
-rw-r--r--boost/serialization/bitset.hpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/boost/serialization/bitset.hpp b/boost/serialization/bitset.hpp
new file mode 100644
index 0000000000..0e109ce29c
--- /dev/null
+++ b/boost/serialization/bitset.hpp
@@ -0,0 +1,75 @@
+/*!
+ * \file bitset.hpp
+ * \brief Provides Boost.Serialization support for std::bitset
+ * \author Brian Ravnsgaard Riis
+ * \author Kenneth Riddile
+ * \date 16.09.2004, updated 04.03.2009
+ * \copyright 2004 Brian Ravnsgaard Riis
+ * \license Boost Software License 1.0
+ */
+#ifndef BOOST_SERIALIZATION_BITSET_HPP
+#define BOOST_SERIALIZATION_BITSET_HPP
+
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <bitset>
+#include <cstddef> // size_t
+
+#include <boost/config.hpp>
+#include <boost/serialization/split_free.hpp>
+#include <boost/serialization/string.hpp>
+#include <boost/serialization/nvp.hpp>
+
+namespace boost{
+namespace serialization{
+
+template <class Archive, std::size_t size>
+inline void save(
+ Archive & ar,
+ std::bitset<size> const & t,
+ const unsigned int /* version */
+){
+ const std::string bits = t.template to_string<
+ std::string::value_type,
+ std::string::traits_type,
+ std::string::allocator_type
+ >();
+ ar << BOOST_SERIALIZATION_NVP( bits );
+}
+
+template <class Archive, std::size_t size>
+inline void load(
+ Archive & ar,
+ std::bitset<size> & t,
+ const unsigned int /* version */
+){
+ std::string bits;
+ ar >> BOOST_SERIALIZATION_NVP( bits );
+ t = std::bitset<size>(bits);
+}
+
+template <class Archive, std::size_t size>
+inline void serialize(
+ Archive & ar,
+ std::bitset<size> & t,
+ const unsigned int version
+){
+ boost::serialization::split_free( ar, t, version );
+}
+
+// don't track bitsets since that would trigger tracking
+// all over the program - which probably would be a surprise.
+// also, tracking would be hard to implement since, we're
+// serialization a representation of the data rather than
+// the data itself.
+template <std::size_t size>
+struct tracking_level<std::bitset<size> >
+ : mpl::int_<track_never> {} ;
+
+} //serialization
+} //boost
+
+#endif // BOOST_SERIALIZATION_BITSET_HPP