On Sunday, 26 January 2014 at 22:32:32 UTC, matovitch wrote:
You mean that two input ranges are created from the immutable
arrays when I call the function ?
Zip doesn't compiles while zip compile. :/
`Zip` must be explicitly instantiated, which allows you to
attempt to instantiate it with head-immutable slices, which isn't
allowed because head-immutable slices aren't input ranges due to
a lack of working `popFront()`.
Here is the implementation of zip :
auto zip(Ranges...)(Ranges ranges)
if (Ranges.length && allSatisfy!(isInputRange, Ranges))
{
return Zip!Ranges(ranges);
}
`zip` is a range constructor function. These are used to allow
IFTI (Implicit Function Template Instantiation) to infer template
arguments, so the user doesn't have to provide them explicitly.
With IFTI, head-immutable and head-const are stripped from slice
types, so even though you pass immutable(int[]), the parameter
type is set to be immutable(int)[], i.e. an mutable slice of
immutable integers. Only the latter is a valid input range.