Get most D type from type
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Mar 17 17:36:21 PDT 2017
On Friday, 17 March 2017 at 23:54:36 UTC, Hussien wrote:
> I am using Parameters and ReturnType which give me the "name"
> of the type used. e.g.,
>
> int foo(SomeEnum)
>
> will give SomeEnum and int for the type respectively.
>
> What I need to do, is also get the D types that these use.
>
> int is int, but SomeEnum is an enum.
>
> Is there a traits function or some way to reduce the derived
> type to it's most primitive D type?
>
> A specific class should give "class", some enum should give
> "enum", an interface "interface", a function should give
> "function", etc.
Parameters!foo[0] == SomeEnum
SomeEnum == enum
if some enum is
SomeEnum : int
{
someValue
}
then
static assert (is(Parameters!foo[0] == T, T : int));
will pass.
More information about the Digitalmars-d-learn
mailing list