Mixins: Using the type name to generate a method name
Robert Rouse
robert.e.rouse at gmail.com
Tue Feb 21 12:07:35 PST 2012
stringof did it.
I'm still reading through the D programming book, so I guess I
hadn't gotten there yet. I did a search in the book and found a
reference.
I'll read more. Thanks :)
On Tuesday, 21 February 2012 at 19:48:18 UTC, Adam D. Ruppe wrote:
> 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