On Sunday, 17 July 2016 at 20:51:42 UTC, Walter Bright wrote:
On 7/13/2016 4:57 AM, Tomer Filiba wrote:
struct MyEnum {
@("SOM") enum SomeMember = 0;
@("ANO") enum AnotherMemberWithAVeryLongName = 1;
string dump() {
... // `this` is a value, not a ref here
}
static MyEnum load(string name) {
...
}
}
Not as nice, but gets the job done. But adding a new aggregate
type comes with a lot of baggage. I'm not convinced the
complexity is worth the benefit, which seems minor.
With a union it's ok, see the sugestion here
https://forum.dlang.org/post/kmqmqxskccaceurut...@forum.dlang.org
members are not part of the aggregate. The size is then just
equal to the common type, used as variable to make bit op like
with a regular enum.
I mean that the OP is asking for a really minor feature while he
could solve the problem himself, in case he really needs it.