I need to use bit flags with more than 32 bits (33 to be exact right now). I tried and find std::bitset doesn't handle more than 32 bits (ulong). Do I have to use vector or there's a way to make bitset to work?
I am limited to c++98 in this project so I can't use boost.
Thanks.
Edit:
I'd like to do something like this:
const uint64 kBigNumber = 1LL << 33;
std::bitset<33> myBitSet;
...
switch(myBitSet) {
case kBigNumber:
// do something
...
}
std::bitset
should work with more or less arbitrary sizes -- it's not normally limited to the size of an unsigned long (though it can look that way, because there's a constructor that builds a bitset based on the bits in an unsigned long).
If that won't work, vector<bool>
may be useful for you, though you should be aware that it's pretty much a vector
in name only -- it is not really a container (i.e., doesn't conform to the normal container requirements).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With