Anycorn Anycorn - 2 months ago 20
C Question

C/C++ efficient bit array

Can you recommend efficient/clean way to manipulate arbitrary length bit array?
right now I am using regular int/char bitmask, but those are not very clean when array length is greater than datatype length.

std vector<bool>
is not available for me.

thanks

Answer

boost::dynamic_bitset if the length is only known in run time.

std::bitset if the length is known in compile time (although arbitrary).