[Issue 19287] New: each only accepts lambdas that take a single argument
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 5 06:55:35 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19287
Issue ID: 19287
Summary: each only accepts lambdas that take a single argument
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: iamthewilsonator at hotmail.com
See https://forum.dlang.org/post/tgnnsqkclbcaejhbiprn@forum.dlang.org for the
motivation.
struct that contain destructors cannot be closed over (I'm not sure why but
thats a different problem) and so
CantCloseMe o; // some struct with a door
somerange.each!(e => foo(o,e)); //Error: variable `o` has scoped destruction,
cannot build closure
fails. But it can't be worked around with
somerange.each!((e,f) => foo(o,f))(o);
Fails with
Error: template somerange.each!((e,f) => foo(o,f)).each cannot deduce function
from argument types !()(SomeRange, CantCloseMe), candidates are:
...
because all of the each functions take only a range or iterable.
--
More information about the Digitalmars-d-bugs
mailing list