__traits(allMembers) and aliases
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 26 04:20:37 PDT 2015
On Tuesday, 25 August 2015 at 12:06:08 UTC, 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've been doing work on this recently. As far as I can tell,
there is no way to do this. The problem is that an alias behaves
exactly like the thing being aliased since it's just a name
replacement, so there are no giveaways like being unable to take
its address like enums. Aliases are more or less invisible.
Hence, having an isAlias trait would be a really good idea.
More information about the Digitalmars-d-learn
mailing list