My thoughts & experiences with D so far, as a novice D coder
deadalnix
deadalnix at gmail.com
Wed Mar 27 10:32:06 PDT 2013
On Wednesday, 27 March 2013 at 16:52:27 UTC, Nick Sabalausky
wrote:
> Honestly, I hate that, too. The problem is that enum is
> (unfortunately)
> intended to do double-duty as a bitfield so you can do
> something like
> this:
>
> enum Options
> {
> FeatureA = 0b0000_0001;
> FeatureB = 0b0000_0010;
> FeatureC = 0b0000_0100;
> FeatureD = 0b0000_1000;
> // etc...
> }
>
> // Use features A and C
> auto myOptions = Options.FeatureA | Options.FeatureC;
>
> That possibility means that D *can't* check for validity as you
> suggest.
>
It can. myOptions is an int here, as Options would decay to its
base type.
More information about the Digitalmars-d
mailing list