Get most D type from type
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Mar 17 19:28:45 PDT 2017
On Friday, 17 March 2017 at 23:54:36 UTC, Hussien wrote:
> What I need to do, is also get the D types that these use.
Those aren't types, they are more like categories of type, so
there's nothing in the language that can represent them to return
(except maybe a string).
Instead, you can test the family with the is expression, like so:
static if(is(SomeEnum == enum))
else static if(is(SomeClass == class))
and so on. you could write a function that checks those (there
are only i think 10 possibilities, enum, class, interface,
struct, union, function, template, module, or basic type, or not
a type at all) and return a string or whatever you choose to
represent them.
More information about the Digitalmars-d-learn
mailing list