Using traits to detect alias declaration

Jonathan M Davis jmdavisProg at gmx.com
Sun Sep 9 20:30:42 PDT 2012


On Monday, September 10, 2012 05:01:05 cal wrote:
> __traits(allMembers), I'd like to be able to detect if 
> a given member is an alias (and get the member that is aliased). 
> Is there a way to do this currently?

No. As far as the compiler is concerned, there is no difference between an 
alias and what it's aliased from.

Now, if you're talking about alias this in particular rather than a type or 
variable, that's a bit different, because it only gets used if the non-alias 
stuff doesn't work. If that's the case, you _might_ be able to determine 
whether something is using alias this by checking that == on the type fails 
and : succeeds (since aside from built-in types, the only times that implicit 
conversions exist are via inheritance or alias this), but that won't tell you 
_what_ was aliased to this. I don't think that there's any way to determine 
that.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list