On Sunday, 20 May 2018 at 01:41:03 UTC, Dr.No wrote:
I'd like to pass a symbol as paramater (class static member0 and at same time get the type of this, something like this:

template myTemp(alias s)
{
        enum myTemp = templateFunction!(??)(s.stringof);
}

the templateFunction has this signature:

int templateFunction(T)(string targetMembername)

but I don't how to get the type name from the give symbol name in myTemp. Can I make this work?

Something like this?

´´´
import std.stdio;

void main()
{
        size_t s;
        auto res = myTemp!s;
}


template myTemp(alias s)
{
        enum myTemp = templateFunction!(typeof(s))(s.stringof);
}


int templateFunction(T)(string targetMembername)
{
        static assert(is(T == size_t));
        assert(targetMembername == "s");
        return 42;
}
´´´

Reply via email to