I have a very simple question: In C++, is there an in-built or straightforward way to group a large (~1000) number of bits (or bools) in a single label such that the inbuilt bit operators function as they do for fundamentals?
e.g. for a long you might write:
unsigned long maximum = ~0;
or one might use:
somenum>>;
Is there an analogous way to do this for a block of memory of arbitrary size?
If not, what are some good alternatives ? I have thought of bit <vectors>, a C union, etc., but these all seem to require handwritten routines for the various bit operations.
Yep! It’s called
std::bitsetand does just that.Hope this helps!