Answer depend on how you combine criteria. There are two most simple cases.
Any match, OR combination. any flag you set will add matches, more flags more matches.
In this case all flags reset (0x0000) will match never. This means no criteria met.
All flags set (0xFFFF) will cause most matches. In case you have complimentary criteria (one of them is set) criteria will match always.
Match is implemented like this: 0!=(filter & criteria)
where filter
is set of criteria to filter and criteria
is set of same flags set on several conditions.
All match, AND combination. any flag you set will filter out some matches, more flags less matches.
In this case all flags reset will match always.
All flags set will cause least matches. If you have mutually exclusive criteria (one set then others reset) when all ones will cause no matches.
E. g. your flags: FLAG_LOGIN
, FLAG_NOLOGIN
. User may be either login or not, so BOTH criteria will never met, and FLAG_LOGIN+FLAG_NOLOGIN
will never match, but 0
will match in any case as none of criteria set.
Match is implemented using this formula: 0==(all_flags & ~filter & ~criteria)
, here filter
and criteria
are same as above and all_flags
is set of all used flags, to exclude unused bits in comparison. (note, expression criteria == (filter & criteria)
is seem more obvious but wrong, because it will cause no matches when no flags ar set in criteria).
If your flag is 1 | 4
and object has 1 | 8
, then first case will have match (because 1
criteria met and one is sufficient) and second case will not have match (4
criteria does not met but you need both 1
and 4
).