Variadic template function?

Daniel Giddings daniel.giddings at gmail.com
Thu Feb 8 02:53:34 PST 2007


both of the following should work:

import std.stdio;

void foo(T, R... )( T element, R remainder )
{
 writefln( element );
 static if( remainder.length > 0 )
  foo( remainder );
}

void bar(T...)( T element )
{
 foreach( e; element )
  writefln( e );
}

void main()
{
 foo(1,2,3,4,5);
 bar(1,2,3,4,5);
}

"Michiel" <nomail at hotmail.com> wrote in message 
news:eqest9$2iuk$1 at digitaldaemon.com...
> Eh, I changed the function name in the post to 'foo' to make it more 
> general (or
> no reason at all, really). But I didn't change the error message 
> accordingly. The
> function name was originally 'set'. 





More information about the Digitalmars-d mailing list