On 26/08/15 12:06 AM, Mike Parker wrote:
Is there a way to determine whether a given symbol is an alias? Consider
this:

```
module funcs;
alias FuncPtr = void function();
@ChooseMe FuncPtr funcPtr;
alias anotherName = funcPtr;
```

Handing this module off to __traits(allMembers), then checking for the
UDA on each member, I can filter out FuncPtr just fine. Unfortunately,
anotherName passes the test, but I don't want it to. Is there anyway I
can distinguish the anotherName alias from funcPtr without tagging it
with a UDA? I can't find any sort of isAlias trait anywhere.

I think a better way may be to check if it is a type or not. An alias appears as a type with the module being the one it is declared in.

While my memory especially at 4am is rusty here:

enum isVarDecl = __traits(compiles, {mixin(GOT ~ " got;");});

Where GOT is assumed to be the string that you got from __traits(allMembers.
It'll be true that it is a variable declaration. False for anything else e.g. a type.

Reply via email to