Bug 15358 – std.range.each does not support opApply methods with arbitrary arity

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-11-18T18:30:00Z
Last change time
2016-12-23T01:04:33Z
Assigned to
nobody
Creator
monkeyworks12

Comments

Comment #0 by monkeyworks12 — 2015-11-18T18:30:45Z
The following code fails because lockstep with 3 arguments defines a trinary opApply, but each only supports up to binary opApply, with one argument being an index: void main(){ import std.container; import std.stdio; import std.algorithm.iteration; import std.range; Array!int ai = [1,2,3,4]; Array!int ai1 = [1,2,3,4]; Array!int ai2 = [1,2,3,4]; auto arange2 = lockstep(ai[],ai1[],ai2[]); //Error: template std.algorithm.iteration.each cannot deduce function from //argument types !((a, b, c) => writeln(a, b, c))(Lockstep!(RangeT! //(Array!int), RangeT!(Array!int), RangeT!(Array!int))), //candidates are: // /opt/compilers/dmd2/include/std/algorithm/iteration.d(820): // std.algorithm.iteration.each(alias pred = "a") //arange2.each!((a,b,c) => writeln(a, b, c)); } Related: https://issues.dlang.org/show_bug.cgi?id=4264 https://issues.dlang.org/show_bug.cgi?id=15357
Comment #1 by greeenify — 2016-12-23T01:04:33Z
This was fixed with https://github.com/dlang/phobos/pull/3837 and is part of DMD since 2.072 ;-)