$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r52637 - trunk/boost/serialization
From: ramey_at_[hidden]
Date: 2009-04-27 19:08:55
Author: ramey
Date: 2009-04-27 19:08:54 EDT (Mon, 27 Apr 2009)
New Revision: 52637
URL: http://svn.boost.org/trac/boost/changeset/52637
Log:
Add support for std::bitset.hpp
Added:
   trunk/boost/serialization/bitset.hpp   (contents, props changed)
Added: trunk/boost/serialization/bitset.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/serialization/bitset.hpp	2009-04-27 19:08:54 EDT (Mon, 27 Apr 2009)
@@ -0,0 +1,71 @@
+/*!
+ * \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
+
+#include <bitset>
+#include <string>
+
+#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, unsigned size>
+inline void save(
+    Archive & ar,
+    std::bitset<size> const & t,
+    const unsigned int version
+){
+    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, unsigned 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, unsigned 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 <unsigned size>
+struct tracking_level<std::bitset<size> >
+    : mpl::int_<track_never> {} ;
+
+} //serialization
+} //boost
+
+#endif // BOOST_SERIALIZATION_BITSET_HPP
+