bit-level logic operations on enums

Steven Schveighoffer schveiguy at yahoo.com
Fri Mar 1 15:05:04 PST 2013


On Fri, 01 Mar 2013 18:00:57 -0500, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:

> I was sure too.  It's not.  Any operation between A types results in A.
>
> writeln(typeof(a + a).stringof); // => A
> writeln(typeof(a << a).stringof); // => A
> writeln(typeof(a * a).stringof); // => A

I should add that in my test code (not the code posted previously), A is  
defined as:

enum A
{
    a = 2
}

So the zero theory is out.  All those result in a non-member value.

-Steve


More information about the Digitalmars-d mailing list