Iterate over symbols in tupleof without instance

Dicebot public at dicebot.lv
Tue Apr 15 05:33:41 PDT 2014


On Tuesday, 15 April 2014 at 12:30:44 UTC, Benjamin Thaut wrote:
> I want to iterate over the symbols, not over the types that the 
> symbols have. I need to iterate over the symbols, because UDAs 
> are attached to the symbols. Because of that none of the here 
> listed solutions work for me.
>
> Here is a small example of what I'm trying to do: 
> http://dpaste.dzfl.pl/4645d6537447
>
> And no, I can not use __traits(allMembers, T) and 
> __traits(getMember, T, m) because some time ago 
> __traits(getMember, ...) was changed so it can no longer access 
> protected members. (obviously it will work if the type that 
> should be iterated over is within the same module, but thats 
> not the case in practice.)
>
> Kind Regards
> Benjamin Thaut

So, what is wrong with this?

void main(string[] args)
{
   Bla bla;
   foreach(index, a; typeof(Bla.tupleof))
   {
     pragma(msg, hasAttribute!(Bla.tupleof[index], 
Property).stringof);
   }
}

http://dpaste.dzfl.pl/b38035362b29


More information about the Digitalmars-d-learn mailing list