|Posted by kdevel|
in reply to Ali Çehreli
Posted in reply to Ali Çehreli
Thanks for your explications!
On Friday, 19 May 2023 at 21:18:28 UTC, Ali Çehreli wrote:
> - std.range.zip can be used instead but it does not provide 'ref' access to its elements.
How/why does sort  work with zipped arrays?
> The following amap example there may be useful for your case but I could not make the types work:
Do you mean using the function pointer does not work?
> // Same thing, but explicitly allocate an array
> // to return the results in. The element type
> // of the array may be either the exact type
> // returned by functions or an implicit conversion
> // target.
> auto squareRoots = new float[numbers.length];
> taskPool.amap!sqrt(numbers, squareRoots);
This even seems to work with a static function pointer:
int main ()
const double  a = [1., 2., 3., 4.];
double  b = [0., 0., 0., 0.];
double function (double) fp = &sqrt;
taskPool.amap!fp (a, b);
Using an automatic variable gives a deprecation warning
main.amap!(const(double), double).amap` function requires a
dual-context, which is deprecated