Serialization on boost::dynamic bitset

Hi, I have to write code for serialization of dynamic bitset. I could well write the code by iterating through the bitset, but i was just wondering, why it is not provided as part of the library. Thanks, Gokul.

Can someone verify whether my code is appropriate? #include <vector> #include <ace/Basic_Types.h> #include <boost/dynamic_bitset.hpp> class Bitmapset { private: friend class boost::serialization::access; template<class Archive> void load(Archive& ar, const unsigned int version); template<class Archive> void save(Archive& ar, const unsigned int version) const; BOOST_SERIALIZATION_SPLIT_MEMBER() friend std::ostream& operator<<(std::ostream& os, const Bitmapset& node); private: boost::dynamic_bitset<ACE_UINT32> m_bits; } template<class Archive> void Bitmapset::save(Archive & ar, const unsigned int version) const { std::vector<ACE_UINT32> blocks; boost::to_block_range<ACE_UINT32>(m_bits, blocks.begin()); ar & blocks; } template<class Archive> void Bitmapset::load(Archive & ar, const unsigned int version) { std::vector<ACE_UINT32> blocks; ar & blocks; boost::from_block_range<ACE_UINT32>( blocks.begin(), blocks.end(), m_bits); } Thanks, Gokul. On Sat, Jul 11, 2009 at 2:14 PM, Gokulakannan Somasundaram < gokul007@gmail.com> wrote:
Hi, I have to write code for serialization of dynamic bitset. I could well write the code by iterating through the bitset, but i was just wondering, why it is not provided as part of the library.
Thanks, Gokul.
participants (1)
-
Gokulakannan Somasundaram