boolean array in struct - help

06/01/2013 09:29 Hikarim#1
Well, i have a struct with an boolean array in it... like this:

Code:
struct abc{
      bool mnzc[MAX];
};
how can i declare MAX? Because if i do it, jut like "int MAX=12;" it wont work...
06/01/2013 10:00 ernilos#2
#define MAX 12
06/01/2013 10:35 MrSm!th#3
^no
const int MAX = 12;
06/01/2013 10:59 TIMΣ™#4
I would say too const int MAX = 12;
06/01/2013 14:15 MrSm!th#5
btw. if it's not absolutely necessary to use an array (because a C function expects it as an argument or whatever), just use std::vector<bool>. It is even optimized to store the values in bits instead of bytes.
06/01/2013 14:19 Schlüsselbein#6
vector<bool> sucks imho. Its no STL-container and it doesnt hold bools. If you want a bitst use std::bitest if you want an array of bools use std::deque<bool>.
06/01/2013 16:32 MrSm!th#7
Quote:
Its no STL-container
But? oO

Quote:
and it doesnt hold bools
saw that as an advantage. the inner representation shouldn't matter in most cases as you know. that's what oop is about :p
06/02/2013 02:16 Schlüsselbein#8
Quote:
But? oO
But anything else. Take a look right here (and at the following links): [Only registered and activated users can see links. Click Here To Register...]
Quote:
saw that as an advantage. the inner representation shouldn't matter in most cases as you know. that's what oop is about
Jep, it shouldn't matter. But in case of case of vector<bool> it does. Thath because vector<bool> is different to vector<T> (where T != bool).

Btw: I can explain later in more detail (now im fucking drunk)
06/02/2013 03:05 MrSm!th#9
Well, I see, vector<T> is guaranteed to behave as a c-style array when it comes to addressing the data buffer (i.e. there is an internal array). But usually you wouldn't need to use it as a c-style array. And if you know that detail, I actually don't see why you would have to prefer bitset.

Anyway, how is it possible then to have a vector of bools, if vector<bool> is no STL container but automatically included in <vector>?
Sure, you can use other containers, but isn't that kinda dirty? Why didn't they think about a proper standard implementation then? If I want to have a vector<bool>, I want to have a vector<bool> and no dequeue<bool> :<
06/02/2013 12:43 gogolus3000#10
const int max 12: