Variadic templates

Lutger lutger.blijdestijn at gmail.com
Thu Nov 2 02:49:50 PST 2006


Walter Bright wrote:
> See http://www.digitalmars.com/d/variadic-function-templates.html
> 
> Why now? Because it's such a pain to do template programming without 
> them, and because I wanted to have a good signals and slots 
> implementation. That was the last piece needed to make S&S work right 
> (unless I'm way off track with it).
> 
> There's a lot of unexplored territory with the tuples, they should be 
> able to do a lot more than the current rather limited ability.

Perhaps boost fusion is one example where this territory is explored. 
I'm very curious to see what some D programmers will do with this.

Two minor mistakes in the examples from 
http://www.digitalmars.com/d/template.html:

Write!(int, char, double).print(1, 'a', 6.8); // prints: args are 1a6.8

should be: Write!(int, char, double).write(1, 'a', 6.8);

And:

void Foo(T t, R r)
{
     writefln(t);
     if (r.length)	// if more arguments
         Foo(r);		// do the rest of the arguments
}

should be:

void Foo(T t, R r)
{
     writefln(t);
     static if (r.length)// if more arguments
         Foo(r);		// do the rest of the arguments
}



More information about the Digitalmars-d mailing list