using __traits to get line number of a member

forkit forkit at gmail.com
Sun Nov 14 04:59:54 UTC 2021


On Sunday, 14 November 2021 at 04:24:09 UTC, Stanislav Blinov 
wrote:
> On Sunday, 14 November 2021 at 04:05:45 UTC, forkit wrote:
>
>> However, there is no isClass method. Why not?
>>
>> How do I determine if a member is a class.. I wonder...
>
> ```
> static if (is(something == class)) { /* ... */ }
> ```
>
> or, if member is an instance
>
> ```
> static if (is(typeof(something) == class)) { /* ... */ }
> ```
>
> Ditto for interfaces, structs, unions.

thanks :-)

works now...

if((is(mixin(member) == class)))
                writeln("This is a class.");



More information about the Digitalmars-d-learn mailing list