Get most D type from type
Hussien via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Mar 17 19:23:01 PDT 2017
On Saturday, 18 March 2017 at 00:36:21 UTC, Nicholas Wilson wrote:
> 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.
I need the general solution. One that simply returns the type.
None of what you said helps...
More information about the Digitalmars-d-learn
mailing list