On 2014-04-04 04:31, Walter Bright wrote:
On 4/3/2014 7:19 PM, bearophile wrote:
I have asked for fully typesafe enums in D,

You can do this:

    struct MyInt {
        int x;
        alias this x;
        ... put your various constraints here ...
    }

to get typesafe enums. In fact, you can use this construct to create a
type that overrides selected behaviors of any other type.

For a more complete implementation of typesafe enums, here's my take:

https://github.com/Biotronic/Collectanea/blob/master/biotronic/enumeration.d

--
  Simen

Reply via email to