Variadic templates

rm roel.mathys at gmail.com
Tue Nov 7 11:46:53 PST 2006


should this work:

 >>>
import std.stdio;

template Templ(T, R ...)
{
	static if (R.length) {
     	const char [] s = "yes";
//		writefln(s);
	} else {
		const char [] s = "no";
//		writefln(s);
	}
}


void main()
{
      mixin Templ!(int,char);
      writefln(s); // can't put this into the template
}
<<<


It compiles, it runs fine, but I'm not using function templates.
otoh, try to bring the lines commented out into play, it won't compile 
anymore.

bye,
roel



More information about the Digitalmars-d mailing list