Iterate over enum

HaraldZealot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 18 14:11:27 PDT 2015


On Saturday, 18 April 2015 at 20:42:09 UTC, Ali Çehreli wrote:
> On 04/18/2015 01:30 PM, HaraldZealot wrote:
>> Is it possible iterate over enum (preferable in compile time) 
>> or at
>> least check that particular value belong to enum?
>
> EnumMembers:
>
>   http://dlang.org/phobos/std_traits.html#EnumMembers
>
> It returns a "static tuple", meaning that a foreach over those 
> members will be a compile-time foreach. (No loop at all at 
> run-time, the body is unrolled for every member.)
>
> Ali

Many thanks


More information about the Digitalmars-d-learn mailing list