Re: taskPool.reduce vs algorithm.reduce

2018-07-19 Thread Malte via Digitalmars-d-learn
On Wednesday, 11 July 2018 at 10:07:33 UTC, Timoses wrote: On Wednesday, 11 July 2018 at 08:31:30 UTC, Dorian Haglund wrote: [...] As the error message says taskPool.reduce is a non-global template. It's embedded in a taskPool struct. I can't say what the reason is that a delegate cannot be

Re: taskPool.reduce vs algorithm.reduce

2018-07-11 Thread Timoses via Digitalmars-d-learn
On Wednesday, 11 July 2018 at 08:31:30 UTC, Dorian Haglund wrote: Hi. I'm trying to use taskPool.reduce with a delegate, for example: import std.parallelism; int main(string[] args) { int f(int a, int b) { if (args.length > 1) return a+b; else return a-b; } auto re

Re: taskPool.reduce vs algorithm.reduce

2018-07-11 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 11 July 2018 at 08:31:30 UTC, Dorian Haglund wrote: But it fails to compile (with gdc 8.1.0, dmd v2.081) complaining that template instance reduce!(f) cannot use local 'f' as parameter to non-global template reduce(functions...) Congratulations! You've just run into issue 571

taskPool.reduce vs algorithm.reduce

2018-07-11 Thread Dorian Haglund via Digitalmars-d-learn
Hi. I'm trying to use taskPool.reduce with a delegate, for example: import std.parallelism; int main(string[] args) { int f(int a, int b) { if (args.length > 1) return a+b; else return a-b; } auto res = taskPool.reduce!f([1, 2, 3]); return 0; } But it fails to c