[Issue 17019] New: std.algorithm.iteration.each should be usable with parallel
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Dec 22 17:24:16 PST 2016
https://issues.dlang.org/show_bug.cgi?id=17019
Issue ID: 17019
Summary: std.algorithm.iteration.each should be usable with
parallel
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: greeenify at gmail.com
The following test fails:
```
unittest
{
import std.algorithm.iteration : each, sum;
import std.parallelism : parallel;
import std.range : iota;
auto logsIndex = new int[10];
parallel(logsIndex).each!((i, ref e) => e += i);
assert(logsIndex.sum == 10.iota.sum);
}
```
while it passes without parallel:
```
unittest
{
import std.algorithm.iteration : each, sum;
import std.parallelism : parallel;
import std.range : iota;
auto logsIndex = new int[10];
logsIndex.each!((i, ref e) => e += i);
assert(logsIndex.sum == 10.iota.sum);
}
```
of course the foreach alternative works as well
```
unittest
{
import std.algorithm.iteration : sum;
import std.parallelism : parallel;
import std.range : iota;
auto logsIndex = new int[10];
foreach (i, ref e; parallel(logsIndex))
e += i;
assert(logsIndex.sum == 10.iota.sum);
}
```
/usr/include/dlang/dmd/std/algorithm/iteration.d(936): Error: template
foo.__unittestL1_3.__lambda1 cannot deduce function from argument types
!()(int), candidates are:
foo.d(8): foo.__unittestL1_3.__lambda1
foo.d(8): Error: template instance foo.__unittestL1_3.each!((i, ref e) => e +=
i).each!(ParallelForeach!(int[])) error instantiating
Failed: ["dmd", "-unittest", "-g", "-v", "-c",
"-of/tmp/.rdmd-1000/rdmd-foo.d-2E6138563669BF9753765C098C72200E/objs/foo.o",
"foo.d", "-I.", "/tmp/.rdmd-1000/stubmain.d"]
This is probably related to https://issues.dlang.org/show_bug.cgi?id=15357
--
More information about the Digitalmars-d-bugs
mailing list