overloading operations for enums
Dominikus Dittes Scherkl via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 26 09:54:01 PDT 2014
Hello.
I want to create some finite algebra, where the elements are
enumerated but operations on them are defined (with composition
tables).
e.g.:
enum color = { white, yellow, red, blue, orange, violet, green,
black };
color a = blue;
a += yellow;
assert(a == green);
is this possible in D?
Because, if I define a struct, I can define operation overloads,
but then I have no enumeration of possible values. But if I
enumerate, I cannot
overload operations.
What have I missed?
More information about the Digitalmars-d-learn
mailing list