fix doc example typo
[boost.git] / boost / serialization / bitset.hpp
blob889de7f22463f146aed080979c8f441926e35332
1 /*!
2 * \file bitset.hpp
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
9 */
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)
15 # pragma once
16 #endif
18 #include <bitset>
20 #include <boost/config.hpp>
21 #include <boost/serialization/split_free.hpp>
22 #include <boost/serialization/string.hpp>
23 #include <boost/serialization/nvp.hpp>
25 namespace boost{
26 namespace serialization{
28 template <class Archive, unsigned size>
29 inline void save(
30 Archive & ar,
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
38 >();
39 ar << BOOST_SERIALIZATION_NVP( bits );
42 template <class Archive, unsigned size>
43 inline void load(
44 Archive & ar,
45 std::bitset<size> & t,
46 const unsigned int /* version */
48 std::string bits;
49 ar >> BOOST_SERIALIZATION_NVP( bits );
50 t = std::bitset<size>(bits);
53 template <class Archive, unsigned size>
54 inline void serialize(
55 Archive & ar,
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
66 // the data itself.
67 template <unsigned size>
68 struct tracking_level<std::bitset<size> >
69 : mpl::int_<track_never> {} ;
71 } //serialization
72 } //boost
74 #endif // BOOST_SERIALIZATION_BITSET_HPP