Juha Nieminen wrote:
> Rafal wrote:
>> wrote:
>>
>>> I know that std::vector<bool> is specialized to store individual
>>> bools as single bits.
>>
>> Actually this is considered a bit of "hack" and AFAIR it will be
>> removed soon (in C++0x?).
>
> Exactly how is it a "hack" and why should it be removed? Has a
> better alternative been suggested?
It's strange because it is the only container that does not store
elements of the contained type. It also uses a proxy class for
vector<bool>::reference, which is not allowed by the standard for any
other container.
The real hack is that the standard assumes that everyone benefits from
a space optimization for vector<bool> and speed optimizations for
vector<everything_else>. Why?
It hasn't been removed so far, and as its section has actually been
edited in the latest draft for the next standard, it is unlikely to go
away anytime soon. We have also seen that other containers, like
std::string and std::array, are allowed to somewhat deviate from the
general container requirements, so why not?
>
> I certainly would like to have some kind of bool data container
> where each bool indeed takes only one bit, to save memory.
Always, or sometimes?
>
> (OTOH, I assume the dynamic bitvector in boost is more of the kind
> of data container people like rather than std::vector<bool>? I
> would be fine with that too, but will such a data container be
> included in the next standard?)
Doesn't seem so (yet).
Bo Persson