Mixins: Using the type name to generate a method name

Adam D. Ruppe destructionator at gmail.com
Tue Feb 21 11:48:17 PST 2012


On Tuesday, 21 February 2012 at 19:42:42 UTC, Robert Rouse wrote:
>     mixin("alias _method " ~ toLower(typeid(T)) ~ ";" );


Try using T.stringof instead of typeid(T).

typeid does a runtime lookup. T.stringof does magic to
get a string representation of the thing at compile time.


Since, in the template, T here is a type, you get a string
of that type.

.stringof is a bit of magic that can work in a lot of places.
last time I checked though, it is pretty poorly documented,
so might take some guess and check to make it work for you.


More information about the Digitalmars-d-learn mailing list