On Monday, 10 September 2012 at 03:30:25 UTC, Jonathan M Davis wrote:
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.

Played around a bit, and this _seems_ to work:

// Detect alias
foreach(member; __traits(allMembers, l.main))
{
static if (__traits(compiles, __traits(identifier, mixin(member))))
   {
      string ident = __traits(identifier, mixin(member));
      if (ident != member)
        /// Detected an alias
   }
}

But I wonder if this is reliable.


Reply via email to