Forbidding implicit conversions from an enum type to an integer

Dennis dkorpel at gmail.com
Tue Apr 2 09:02:03 UTC 2019


On Tuesday, 2 April 2019 at 08:38:28 UTC, Per Nordlöw wrote:
> Is there a way (compiler flag) to forbid implicit conversions 
> from an enum type to integer types?

You can make the enum type not an integer type.

```
struct Int{int i;}

enum E: Int {
     first = Int(0),
     second = Int(1),
}
```


More information about the Digitalmars-d-learn mailing list