This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
bool
- To: egcs at cygnus dot com
- Subject: bool
- From: Andrew Borthwick <borthwic at johnson dot cs dot nyu dot edu>
- Date: Tue, 11 Nov 1997 11:27:17 -0500 (EST)
Hi,
I'm looking for some advice on boolean variables in g++. I wrote a little
test program and found that with the 1997/11/05 snapshot, a bool has a size of 4
bytes. While I recognize that this is not a valid comparison because of the use
of pointers, I found that "sizeof(vector<bool>)" gives a size of 28 bytes as did
"sizeof(bit_vector)". My questions, then are,
--Am I better off using vector<bool> or bit_vector if I want a vector of
booleans?
--Am I correct that if space is a concern, I am better off using a "char" than a
"bool" because the former takes one byte and the latter takes four?
Thanks,
Andrew Borthwick