This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bool
- To: Andrew Borthwick <borthwic at johnson dot cs dot nyu dot edu>
- Subject: Re: bool
- From: Branko Cibej <branko dot cibej at hermes dot si>
- Date: Wed, 12 Nov 1997 11:46:06 +0100
- Cc: egcs at cygnus dot com
- Organization: HERMES SoftLab
- References: <Pine.GSO.3.92.971111180847.13267D-100000@johnson.cs.nyu.edu>
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