[Issue 22008] foreach over enum members

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 8 21:13:23 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22008

Dlang Bot <dlang-bot at dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #1 from Dlang Bot <dlang-bot at dlang.rocks> ---
@TungstenHeart created dlang/dmd pull request #12650 "fix 22008 - allow to
iterate over enum members without `__traits`" fixing this issue:

- fix 22008 - allow to iterate over enum members without `__traits`

  Adds the support to recognize EnumDeclaration as forerach aggregate.
  The following code

  ```d
  foreach (e; __traits(allMembers, E))
  {
      auto v = __traits(getMember, E, e);
  }
  ```

  can be more simply written

  ```d
  foreach (v; E) {}
  ```

  This saves AST space, copies, time spent in semanticTraits with very few new
dmd code.

https://github.com/dlang/dmd/pull/12650

--


More information about the Digitalmars-d-bugs mailing list