April 27, 2009 Bug? enum inside class limited to integral values | ||||
|---|---|---|---|---|
| ||||
I don't know if its a bug or intended behavior, the documentation doesn't mention this.
Enums in the global scope can allow any type for declarations:
---
enum {
FOO = 1, BAR = "foobar"
}
---
However, when using the same syntax within a class, the compiler spits out a nasty Error: Integer constant expression expected instead of "foobar". When using the enum as a manifest constant, (enum BAR = "foobar";) it works just fine.
If this behavior is intentional, may I ask why? I fail to assume a rationale behind having different behaviors from global scope to class scope for this.
| ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply