On Sunday, 26 January 2014 at 22:19:47 UTC, Stanislav Blinov wrote:
On Sunday, 26 January 2014 at 21:49:37 UTC, matovitch wrote:

void main() {

   immutable int[] B = [ 1, 2, 3 ];
   immutable int[] C = [ 4, 5, 6 ];
   auto BC = zip(B, C);
   writeln(BC);
}

Here B and C aren't inputRange thought acording to the template constraint of zip there should be. How can it compiles ?

B and C aren't, but B[] and C[] are. That's what's going on when
you pass an array as function argument: a full slice is taken.
See for yourself:

void foo(R)(R r) {
     writeln(R.stringof);
}

foo(B); // will print immutable(int)[]


You mean that two input ranges are created from the immutable arrays when I call the function ?

Zip doesn't compiles while zip compile. :/

Here is the implementation of zip :

auto zip(Ranges...)(Ranges ranges)
    if (Ranges.length && allSatisfy!(isInputRange, Ranges))
{
    return Zip!Ranges(ranges);
}

Reply via email to