dynamic_bitset, bitset, etc
I find that I frequently want a class that provides the capabilities of a boost::dynamic_bitset, but that i want to be able to load the values all at once from a huge block of binary data. The exact use case is that I'm reading block data off of a disk, and in most modern file systems there's a very large chunk of data at the beginning that is just a series of bits that specify whether or not particular blocks are allocated. So I issue an I/O to read a chunk of this bitmap, then I just want to tell the class "do a huge memcpy and use this block of data as your internal buffer". Or better yet, member functions that a) give direct access to the internal buffer and b) tell me how many bytes the internal buffer is, and c) let me resize the internal buffer to hold x bits. There's vector<bool>, std::bitset, boost::dynamic_bitset, and boost::bitset. I understand why vector<bool> can't support this, but is there some fundamental reason why this seemingly simple operation is not supported on any available implementation of a bit set anywhere? Or is it supported and I'm just overlooking the function necessary to do it? I see there's a constructor that takes a BlockIterator, but I want it to ultimately boil down to a memcpy, not a for loop.
participants (1)
-
Zachary Turner