[Issue 24540] Add order/index to enum member to return its position
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon May 6 15:59:18 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24540
Nick Treleaven <nick at geany.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nick at geany.org
--- Comment #2 from Nick Treleaven <nick at geany.org> ---
(In reply to apham from comment #0)
> void set(Foo e)
> {
> v |= 1 << e.order;
> }
>
> bool isSet(Foo e)
> {
> return (v & (1 << e.order)) != 0;
> }
It's not possible to take a runtime enum value and produce its index in an enum
without some runtime overhead.
Another issue is that `e.order` is already valid code, meaning call `order(e)`.
--
More information about the Digitalmars-d-bugs
mailing list