an enum inside another enum

Jacob Carlborg doob at me.com
Thu Jul 26 04:47:04 PDT 2012


On 2012-07-26 13:40, maarten van damme wrote:
> Hi, would the response to this question :
> http://stackoverflow.com/questions/757684/enum-inheritance be the same
> for D?
>
> I have these two enums:
> enum first : string{
>   a="a",
>   b="b"
> }
>
> enum second : string{
>   a=first.a,
>   b=first.b,
>   c="c"
> }
>
> Is there a way to make this cleaner? I don't mind having something like
> second.firstchar.a
> with firstchar  beeing a "first" enum.
>
> To do that I would need to tell the enum that it can also use the type
> "first" because in the end, that is a string too...

I'm pretty sure it's possible to do with some meta programming magic.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list