* Re:bool
@ 1997-11-11 15:29 Andrew Borthwick
1997-11-12 2:47 ` bool Branko Cibej
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Borthwick @ 1997-11-11 15:29 UTC (permalink / raw)
To: egcs
Per Bothner:
> sizeof(bool) must be one.
> Any other choice will be "unexpected" by reasonable progragrammers.
I totally agree. This behavior was certainly unexpected by me.
> Er - what has sizeof to do with how bits are packed? Obviously, sizeof
> will only tell you the fixed (overhead) size. If you look at
> bit_vector, you will find that it does use 1 bit per bool.
My apologies for a somewhat poor choice of words on the subject of vector<bool>
vs. bit_vector.
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?
Thanks,
Andrew Borthwick
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: bool
1997-11-11 15:29 Andrew Borthwick
@ 1997-11-12 2:47 ` Branko Cibej
0 siblings, 0 replies; 2+ messages in thread
From: Branko Cibej @ 1997-11-12 2:47 UTC (permalink / raw)
To: Andrew Borthwick; +Cc: egcs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-11-12 2:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-11 15:29 Andrew Borthwick
1997-11-12 2:47 ` bool Branko Cibej
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).