[C++-sig] Bitflags
David Abrahams
dave at boost-consulting.com
Sun Dec 15 00:32:23 CET 2002
"M. Evans" <datafeed at SoftHome.net> writes:
>> No... what I meant by flags was:
>>
>> enum Fu { x = 1, y = 2, z = 4 };
>>
>> Fu combined = x | y | z;
>
> Commonly called "bitflags," and in my book, deprecated -- though I have
> used them extensively. Their main advantage is syntactical. I don't
> know the context here precisely, but bitflags make combinations of
> "rules" or "options" easy to write.
>
> The problem is the limitation thus imposed on the number of possible
> options (e..g 16 or 32).
The point is that the library is designed to make it easy to use
common C++ idioms from Python, not to pass judgement on which idioms
are good or bad.
If it were impossible to construct unnamed values of a wrapped enum,
it would interfere with common use cases.
--
David Abrahams
dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution
More information about the Cplusplus-sig
mailing list