Can someone verify whether my code is appropriate?
#include <vector>
#include
#include
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 m_bits;
}
template<class Archive>
void Bitmapset::save(Archive & ar, const unsigned int version) const
{
std::vector blocks;
boost::to_block_range(m_bits, blocks.begin());
ar & blocks;
}
template<class Archive>
void Bitmapset::load(Archive & ar, const unsigned int version)
{
std::vector blocks;
ar & blocks;
boost::from_block_range( 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.