Get most D type from type
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Mar 17 22:15:07 PDT 2017
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");
}
More information about the Digitalmars-d-learn
mailing list