3 * \brief Provides Boost.Serialization support for std::bitset
4 * \author Brian Ravnsgaard Riis
5 * \author Kenneth Riddile
6 * \date 16.09.2004, updated 04.03.2009
7 * \copyright 2004 Brian Ravnsgaard Riis
8 * \license Boost Software License 1.0
10 #ifndef BOOST_SERIALIZATION_BITSET_HPP
11 #define BOOST_SERIALIZATION_BITSET_HPP
13 // MS compatible compilers support #pragma once
14 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
20 #include <boost/config.hpp>
21 #include <boost/serialization/split_free.hpp>
22 #include <boost/serialization/string.hpp>
23 #include <boost/serialization/nvp.hpp>
26 namespace serialization
{
28 template <class Archive
, unsigned size
>
31 std::bitset
<size
> const & t
,
32 const unsigned int /* version */
34 const std::string bits
= t
.template to_string
<
35 std::string::value_type
,
36 std::string::traits_type
,
37 std::string::allocator_type
39 ar
<< BOOST_SERIALIZATION_NVP( bits
);
42 template <class Archive
, unsigned size
>
45 std::bitset
<size
> & t
,
46 const unsigned int /* version */
49 ar
>> BOOST_SERIALIZATION_NVP( bits
);
50 t
= std::bitset
<size
>(bits
);
53 template <class Archive
, unsigned size
>
54 inline void serialize(
56 std::bitset
<size
> & t
,
57 const unsigned int version
59 boost::serialization::split_free( ar
, t
, version
);
62 // don't track bitsets since that would trigger tracking
63 // all over the program - which probably would be a surprise.
64 // also, tracking would be hard to implement since, we're
65 // serialization a representation of the data rather than
67 template <unsigned size
>
68 struct tracking_level
<std::bitset
<size
> >
69 : mpl::int_
<track_never
> {} ;
74 #endif // BOOST_SERIALIZATION_BITSET_HPP