Suppose I have a byte
structure, like this :
struct one_byte
{
char b1 : 1,
b2 : 1,
b3 : 1,
b4 : 1,
b5 : 1,
b6 : 1,
b7 : 1,
b8 : 1;
}foo;
In some cases I'll need to check (foo == 0)
, then I have to do eight commands :
if(foo.b1 == 0 &&
foo.b2 == 0 &&
foo.b3 == 0 &&
...and so on
Is there any portable & convenient way which can instantly check zero value only with a single command? I tried functions & templates, they perform very slowly. And I tried union, my compiler doesn't support bit[array]....