Boost logo

Boost :

Subject: Re: [boost] Dynamic_bitset and access to underlying storage
From: Paul Fee (pfee_at_[hidden])
Date: 2010-06-29 04:24:45


Iain K. Hanson wrote:

> Hi,
>
> I need to use a bitset with contiguous storage so that I can pass it to
> a system call. Although I can't see it in the documentation, I know from
> reading the code, that dynamic bitset is implemented in terms of
> std::vector.
>
> Also, whilst I don't need the run time resizing that dynamic bitset
> provides, I do need to be able to use up to at least 64K bits,
>
> So, is there any chance of an additional member function+ that returns a
> pointer to the zero'eth element of the underlying vector?
>
> regards
>
> /ikh

I encountered a similar problem when trying to serialize an object that had
a dynamic_bitset as a member.

http://comments.gmane.org/gmane.comp.lib.boost.devel/198466

Taking a lead from how std::bitset is serialized, I limited myself to the
existing API. However that's only a limitation with std objects where the
API is frozen. With boost::dynamic_bitset I should have taken advantage of
the ability to change the source and made the serialization functions
friends.

Instead I made use of boost::dynamic_bitset::to_block_range(). If that
meets your needs, you can avoid an API change.

See dynamic_bitset.hpp within my ZIP file for an example.
http://www.boostpro.com/vault/index.php?directory=serialization

Thanks,
Paul


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk