M
Martin Dickopp
Christian Bau said:You say that logical xor is used much more rarely than logical and/or.
Question: Has anybody _ever_ found a situation where they would have
wanted a logical xor?
Yes. I often use the bits of an `unsigned int' struct member to
represent a number of two-state attributes of an object, and
to test for (a combination of) attributes, I use the idiom
if (x->flags & FLAG_FOO) ...
if ((x->flags & FLAG_BAR) || (y->flags & FLAG_BAZ)) ...
where the tokens starting with FLAG_ are macros that expand to an
unsigned int constant expression with one and only one bit that is
set to 1. For symmetry reasons, I would prefer it if I could also
write
if ((x->flags & FLAG_BLAH) ^^ (y->flags & FLAG_BLUBB)) ...
IMHO, that would look nicer (i.e., more like similar expressions
involving && or ||) than the alternatives.
Martin