On Saturday, 18 March 2017 at 05:15:07 UTC, Mike Parker wrote:
On Saturday, 18 March 2017 at 02:23:01 UTC, Hussien wrote:


I need the general solution. One that simply returns the type. None of what you said helps...

string dtype(T)() {
    static if(is(T == enum)) return "enum";
    else static if(is(T == class)) return "class";
    else static if(is(T == struct)) return "struct";
    // etc...
}

void main() {
    struct Foo {};
    assert(dtype!Foo == "struct");
}

So you are telling me there is no way to do this easily? I have to fill in the // etc part with all the possible types that can exist in D? I guess there could be a default that simply returns the typeof, but just seems like a hack overall.


Reply via email to