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
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
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
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
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
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;
}