Concat enum of strings into one string

Andrey saasecondbox at yandex.ru
Tue Aug 14 14:37:33 UTC 2018


On Tuesday, 14 August 2018 at 14:07:23 UTC, Timoses wrote:
> Here's one version:
>
> template StringEnumValues(alias Enum)
> {
>     import std.traits : EnumMembers;
>     string[] StringEnumValues()
>     {
>         string[] enumValues;
>      	static foreach (member; EnumMembers!Enum)
>             enumValues ~= member;
>         return enumValues;
>     }
> }
>
> import std.string : join;
> pragma(msg, StringEnumValues!Type.join(" "));

Thank you. Hmm, I thought that standard library already has this 
stuff.


More information about the Digitalmars-d-learn mailing list