This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bool


Andrew Borthwick wrote:

>     I'm still not entirely clear.  Am I correct that bit_vector gives me
> 1 bit per bool but vector<bool> does not?  If this is so, couldn't vector be
> easily specialized for vector<bool> to give this functionality in a more
> standard fashion?

    There was a long and heated debate about that some time ago in comp.std.c++. I
don't know what the status is now, but at that time the draft standard required
vector<bool> to be specialised so that it used one bit per bool, like bit_vector
does. The central problem was the very same space-vs.-time trade-off we have here.

Personally I think that having two different containers is the correct solution:
vector<bool> for fast access and bit_vector for compact storage -- and you can
always compromise with a vector<unsigned char>.

--
Branko Cibej   <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
phone: (++386 61) 186 53 49  fax: (++386 61) 186 52 70




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]