enum-indexed arrays
Baz via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Sep 20 15:13:29 PDT 2014
On Saturday, 20 September 2014 at 22:00:24 UTC, bearophile wrote:
> Nordlöw:
>
>> should be
>>
>> Enumerator start = Enumerator.min
>
> This also requires the enum to have adjacent values (in general
> enums can skip values).
>
> Bye,
> bearophile
Not true, because you can use std.traits.EnumMembers to prepare
an enum member rank lookup table, so that values have even not be
consecutive.
there is an example here:
http://dlang.org/phobos/std_traits.html#EnumMembers
and a concret application in this personal project (e.g line 111):
https://github.com/BBasile/bitSet/blob/master/import/bitsets/bitsets.d
More information about the Digitalmars-d-learn
mailing list