April 15, 2014 Re: Iterate over symbols in tupleof without instance | ||||
---|---|---|---|---|
| ||||
Posted in reply to Benjamin Thaut | 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 |
April 15, 2014 Re: Iterate over symbols in tupleof without instance | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | Am 15.04.2014 14:33, schrieb Dicebot:
>
> 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
Nothing, thanks for the solution. It didn't come to my mind, to use the index from iterating over the type tuple to index the symbol tuple.
Kind Regards
Benjamin Thaut
|
Copyright © 1999-2021 by the D Language Foundation