Extending bitfields to enumerations of any enumerator type
Per Nordlöw
per.nordlow at gmail.com
Wed Oct 8 20:37:02 UTC 2025
Given
```d
struct S {
Field field:1;
}
```
, is there a reason why
```d
enum Field : string { none = [], dot = "." }
```
isn't allowed and errors as
```
(1,34): Error: bitfield type `FieldNamePrefix` is not an integer
type
```
?
Instead I currently have to encode this as
```d
enum Field : ubyte { none, dot }
string toString(in Field arg) pure nothrow @nogc {
final switch (arg) with (arg) {
case none: return [];
case dot: return ".";
}
}
```
.
More information about the Digitalmars-d
mailing list