[Issue 2599] Two variadic parameters should be accepted

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 25 07:09:45 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2599





------- Comment #4 from andrei at metalanguage.com  2009-01-25 09:09 -------
(In reply to comment #3)
> > When instantiated explicitly, all explicit arguments are eaten by 
> > T1.  This is the purpose of the pattern: pass some explicit 
> > arguments, then deduce some more implicitly.
> 
> In the current template system, a template is instantiated either implicitly or
> explicitly - no in-between.

Try this at home:

void fun(T1, T2)(T2 x)
{
}

void main()
{
    fun!(int)("a");
}


> To allow part-explicit, part-implicit template instantiations like you're
> asking for would be in itself a change in the language that must come first.

Already has (incidentally at my request.) It's used in much of std.algorithm.

> > Currently this is possible, but only with one ellipsis.
> 
> I'm not sure what you mean by this....

This works:

void fun(T1, T2, T3...)(T2 x, T3 xs)
{
}

void main()
{
    fun!(int)("a");
}

This doesn't, which is another bug:

void fun(T1, T2...)(T2 xs)
{
}

void main()
{
    fun!(int)("a");
}


> BTW your workaround can be written more simply:
> 
>     template f(T1...) {
>         void f(T2...)(T2 args) { ... }
>     }

Thanks!


-- 



More information about the Digitalmars-d-bugs mailing list