Bitfield-style enum to strings?

Nick Sabalausky via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 7 14:41:06 PDT 2015


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.



More information about the Digitalmars-d-learn mailing list