Bitfield-style enum to strings?

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 7 18:17:59 PDT 2015


On Thursday, 7 May 2015 at 21:41:06 UTC, Nick Sabalausky wrote:
> On 05/07/2015 05:19 PM, Justin Whear wrote:
>> On Thu, 07 May 2015 16:55:42 -0400, Nick Sabalausky wrote:
>>
>>>      // There's gotta be a better way to convert 
>>> EnumMembers!T // to a
>>>      range, right? But std.range.only() didn't work, // due 
>>> to a
>>>      template instantiation error.
>>>      T[] members;
>>>      foreach(m; EnumMembers!(T))
>>>          members ~= m;
>>
>> T[] members = [ EnumMembers!T ];
>>
>
> Doh! Yup, that works.
>
> Still, I would think there should be a way to do it without 
> allocating an array. But it's not a huge deal right now though.

You could also do `TypeTuple!(EnumMembers!T))` I believe.


More information about the Digitalmars-d-learn mailing list