Why can't typeof() be used in member method?

Andre Pany via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 26 09:50:35 PDT 2017


On Wednesday, 26 July 2017 at 14:05:12 UTC, Adam D. Ruppe wrote:
> On Wednesday, 26 July 2017 at 13:51:05 UTC, Andre Pany wrote:
>> How can I fix this issue?
>
> I would just do
>
>        typeof((new TBounds).Left) m;
>
>
> so then it is clear that you want a non-static member.

In my productive scenario I try to check whether a class (TLabel) 
has a specific member ("Margins.Left", "TextSettings.Font.Size").

mixin(`static if (!__traits(compiles, 
typeof(`~T.stringof~`.`~p.name~`))) {
...
}

This coding is within a member method and due to the issue with 
typeof it is failing.
Creating new class for checking whether the class has a specific 
member is not possible in my scenario, as a DLL call is involved 
and I need the result (member available) as condition for static 
if.

Due you think typeof should work within member methods and I 
should file an issue?

Kind regards
André




More information about the Digitalmars-d-learn mailing list