Is flags enum needed in Phobos?
Denis Shelomovskij
verylonglogin.reg at gmail.com
Tue Sep 25 10:14:27 PDT 2012
.NET has FlagsAttribute, Java has EnumSet. Looks like we need this too.
How about to add a library solution to Phobos?
My variant is here (search for `flagEnum`):
https://bitbucket.org/denis_sh/misc/src/tip/stdd/typecons.d
It has a bug and I have no idea how to fix it:
`AB.init |= AB.a` and `AB.a |= AB.a` are allowed.
(no, we can't make `AB.a` const to disallow the second case because it
will disallow this: `auto a = AB.a; a |= AB.a;`)
Also I'm not sure:
* Should we support converting from a number to a flag enum?
* If so, should we support values not from enum flags or throw
exceptions (it may be configurable)?
* Is `flagEnum` an appropriate name?
--
Денис В. Шеломовский
Denis V. Shelomovskij
More information about the Digitalmars-d
mailing list