Re: How to mixin each element of tuple

2011-12-21 Thread Michal Minich
On 20. 12. 2011 16:20, Timon Gehr wrote: struct Item1(T){} struct Item2(T){} mixin template getItems(Items ...){ static if(Items.length) { private alias Items[0] _item; mixin _item!int; mixin getItems!(Items[1..$]); } } struct Group(Items...) { mixin getItems!Items; } void main(){ alias Group

Re: How to mixin each element of tuple

2011-12-20 Thread bearophile
Timon Gehr: > I think having static foreach would greatly benefit the language. Vote here! :-) http://d.puremagic.com/issues/show_bug.cgi?id=4085 Bye, bearophile

Re: How to mixin each element of tuple

2011-12-20 Thread Timon Gehr
On 12/20/2011 07:13 PM, bearophile wrote: Michal Minich: struct Group (Items ...) { // how to do this? ... no static foreach :( static foreach (I; Items) In D if you use foreach on a typeTuple you get a static foreach. Bye, bearophile Yes, but foreach cannot be used in declaratio

Re: How to mixin each element of tuple

2011-12-20 Thread bearophile
Michal Minich: > struct Group (Items ...) > { > // how to do this? ... no static foreach :( > static foreach (I; Items) In D if you use foreach on a typeTuple you get a static foreach. Bye, bearophile

Re: How to mixin each element of tuple

2011-12-20 Thread Timon Gehr
On 12/20/2011 02:32 PM, Michal Minich wrote: My naive approach doesn't works struct Item1 (T) {} struct Item2 (T) {} struct Group (Items ...) { // how to do this? ... no static foreach :( static foreach (I; Items) mixin I!(int); } void main () { alias Group!(Item1, Ite

How to mixin each element of tuple

2011-12-20 Thread Michal Minich
My naive approach doesn't works struct Item1 (T) {} struct Item2 (T) {} struct Group (Items ...) { // how to do this? ... no static foreach :( static foreach (I; Items) mixin I!(int); } void main () { alias Group!(Item1, Item2) G; }