Using __traits(getMember...) in alias statement

2011-11-17 Thread Tobias Pankrath
It would be cool, if the following would be possible. immutable string MemberID = M; struct A {} struct B { alias A M; } template Member(T) { static if(__traits(hasMember, T, MemberID)) { alias __traits(getMember, T, MemberID) Member; } else alias

Re: Using __traits(getMember...) in alias statement

2011-11-17 Thread Timon Gehr
On 11/17/2011 06:12 PM, Tobias Pankrath wrote: It would be cool, if the following would be possible. immutable string MemberID = M; struct A {} struct B { alias A M; } template Member(T) { static if(__traits(hasMember, T, MemberID)) { alias __traits(getMember, T,

Re: Using __traits(getMember...) in alias statement

2011-11-17 Thread Tobias Pankrath
This helps a lot with the current state of affairs: template ID(alias x){alias x ID;} It will even allow funny things like this: alias ID!((a,b){return a+b;}) add; static assert(add(1,2) == 3); Nice to know, thanks!

Re: Using __traits(getMember...) in alias statement

2011-11-17 Thread Timon Gehr
On 11/17/2011 06:41 PM, Timon Gehr wrote: On 11/17/2011 06:12 PM, Tobias Pankrath wrote: It would be cool, if the following would be possible. immutable string MemberID = M; struct A {} struct B { alias A M; } template Member(T) { static if(__traits(hasMember, T, MemberID)) { alias