Lockstep iteration in parallel: Error: cannot have parameter of type `void`

kdevel kdevel at vogtner.de
Fri May 19 09:17:32 UTC 2023


```
import std.range;
import std.parallelism;

void vec_op (double [] outp, const double [] inp,
    double function (double) f)
{
    foreach (ref a, b; parallel (lockstep (outp, inp)))
       a = f (b);
}
```

Should this compile? dmd says

```
[...]/src/phobos/std/parallelism.d(4094): Error: cannot have 
parameter of type `void`
[...]/src/phobos/std/parallelism.d(4095): Error: cannot have 
parameter of type `void`
[...]/src/phobos/std/parallelism.d(3619): Error: template 
instance `std.parallelism.ParallelForeach!(Lockstep!(double[], 
const(double)[]))` error instantiating
lspar.d(7):        instantiated from here: 
`parallel!(Lockstep!(double[], const(double)[]))`
```


More information about the Digitalmars-d-learn mailing list