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]

bool


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





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