I need resizable bool array with tightly packed data. i mean one bit = one bool value.
std::vector<bool> is, as I've already said, tightly packed.
Second thing is that I will use millions of instances of this class. And vector<bool>
requires (with zero entries) 20 bytes of memory. At start. Thats too much.
Therefore I have decided to create a class that has ability to resize, contains chars, and has ability to access every bit in char.
The only last problem is how to resize this fast.
You need a minimum of three pointers or integers; one to hold your buffer; one to hold the allocated buffer size, or the end of the buffer, so you know when to resize; and one to hold the current size, or the current write location. Assuming two pointers and an integer, that adds up to 20 bytes (assuming a 64 bit system with 64 bit pointers and 32 bit integers). At most you can reduce two of those pointers to another integer, and perhaps the integers to smaller integer types if you want to limit the bit size, but you're still aiming at at least 10 bytes per vector.
Not to mention that there are already plenty of already implemented dynamic bit field classes.
Why did You guys vote down?
Perhaps because you came out as arrogant with your uninformed comment? You argued, for example, that you couldn't use the vector because you had to store your bools tightly packed, but an
std::vector<bool> is already tightly packed. You also came out as it was something very obvious, which it apparently wasn't.
You could very easily just have stated your reasons without making such a statement.