can I generate an enum from a typelist?

Rene Zwanenburg renezwanenburg at gmail.com
Tue Apr 8 05:11:53 PDT 2014


On Tuesday, 8 April 2014 at 08:31:16 UTC, Vlad Levenfeld wrote:
> Ok, starting to feel a bit sheepish at this point, that 
> constructor was unnecessarily verbose:
>
> this (T) (T layer)
> {
> 	import std.string: toLower;
> 	mixin ("this."~toLower (T.stringof)~"= layer;");
> 	this.type = cast (const) typeid (T);
> }
>
> ...is what I have settled on.

Depending on what you're exactly trying to do, you may be able to 
simplify your code using Algebraic [1] from std.variant.

> Sorry for all the noise! There doesn't seem to be a way to edit 
> posts here...

Yeah, the forum is actually a web front end for the newsgroup ;)


[1] http://dlang.org/phobos/std_variant.html#.Algebraic


More information about the Digitalmars-d-learn mailing list