On Sunday, January 15, 2012 03:53:09 Nick Sabalausky wrote: > Is there a way to get the name of an enum value at compile-time? > > For instance: > > import std.stdio; > enum Foo { hello } > void main() > { > writeln(Foo.hello); > } > > That prints "hello". But what I need is to get "hello" into a string at > compile-time. > > Of course, I could just manually write a ctfe-able "fooToString()", or > implement something like std.typecons.defineEnum (which appears to be > deprecated now). But I'm wondering if I'm overlooking a better solution.
to!string(Foo.hello) - Jonathan M Davis