On Saturday, 6 February 2021 at 14:39:38 UTC, Jeff wrote:
So, I'm guessing there's something going on under-the-hood using the ~ operator with the enum and I'd like to understand what it is.

Enum to string conversion is usually implemented using the name of the enum member, regardless of it's value (which might be any type).

String concatenation is not defined for A, so the enum member is implicitly converted to it's base type (see [1], paragraph 5).

Likewise, if there's an easier method of getting the "value of enum" I haven't discovered yet, that'd be just as nice to know. ;)


You can use an is expression to determine the base type...

```
is(A BaseType == enum)
```

...and use `cast(BaseType) A.foo`

[1] https://dlang.org/spec/enum.html#named_enums

Reply via email to