[Issue 22008] New: foreach over enum members
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 8 21:04:18 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22008
Issue ID: 22008
Summary: foreach over enum members
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: b2.temp at gmx.com
Given the declaration
---
enum E {e1, e2}
---
the following code
---
foreach (v; E)
{
// use v
}
---
could be semantically equivalent to
---
foreach (e; __traits(allMembers, E))
{
auto v = __traits(getMember, E, e);
{
// use v
}
}
---
--
More information about the Digitalmars-d-bugs
mailing list