On 17/09/12 14:42, Andrej Mitrovic wrote:
Related: http://d.puremagic.com/issues/show_bug.cgi?id=8676

A lot of code could be stripped if there was a way to set an optional
last parameter for variadics. lockstep could then be written as:

auto newLockstep(Args...)(Args args, StoppingPolicy stoppingPolicy =
StoppingPolicy.shortest)
     if (allSatisfy!(isInputRange, staticMap!(Unqual, Args)))
{
     static if (Args.length > 1)
     {
         return Lockstep!(Args)(args, stoppingPolicy);
     }
     else
     {
         return args[0];
     }
}

but if you don't specify the last StoppingPolicy argument at the call
site it won't compile:

foreach (x, y; newLockstep(arr1, arr2)) { }

test.d(32): Error: template test.newLockstep does not match any
function template declaration
test.d(14): Error: template test.newLockstep(Args...) if
(allSatisfy!(isInputRange,staticMap!(Unqual,Args))) cannot deduce
template function from argument types !()(int[],int[])

That just looks like a bug to me. Please enter it in Bugzilla.


Reply via email to