[Issue 15357] Cannot call std.algorithm.iteration.each on the result of std.range.lockstep
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Nov 18 11:57:15 PST 2015
https://issues.dlang.org/show_bug.cgi?id=15357
Alex Parrill <initrd.gz at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |initrd.gz at gmail.com
--- Comment #3 from Alex Parrill <initrd.gz at gmail.com> ---
>From looking at the code of `each`, it seems to be intended to only work on
opApply structs that only pass one value per iteration; if you instantiate
`each` with a two-argument function, `each` supplies the index of the current
element as the first parameter, and the element itself as the second element.
The problem is that the latter case is implemented via a standard foreach loop,
i.e. `foreach(i, elem; iter)`; if iter returns pairs of elements, then the `i`
value is hijacked to become the first element instead.
So the question is whether `each` should support n-ary opApply iterators at
all. If yes, then the opApply case for `each` should be expanded; if no, then
some additional checks should be placed on `each` to prevent accepting
`opApply` functions that pass in more than 1 element.
--
More information about the Digitalmars-d-bugs
mailing list