25.09.2012 21:14, Denis Shelomovskij пишет:
.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?




Just for those who are interested in my `flagEnum` implementation:

It is in https://github.com/denis-sh/phobos-additions/ project now.

Docs (with links to source) here:
http://denis-sh.github.com/phobos-additions/unstd.typecons.html

--
Денис В. Шеломовский
Denis V. Shelomovskij

Reply via email to