My thoughts & experiences with D so far, as a novice D coder
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Wed Mar 27 10:48:24 PDT 2013
On Wed, 27 Mar 2013 18:32:06 +0100
"deadalnix" <deadalnix at gmail.com> wrote:
> 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.
Options myOptions = Options.FeatureA | Options.FeatureC;
More information about the Digitalmars-d
mailing list