Scientific computing and parallel computing C++23/C++26

forkit forkit at gmail.com
Thu Jan 13 20:07:51 UTC 2022


On Thursday, 13 January 2022 at 01:19:07 UTC, H. S. Teoh wrote:
>
> ..... But still, it doesn't have to be as complex as languages 
> like C++ make it seem.  In the above example I literally just 
> added ".parallel" to the code and it Just Worked(tm).
>
>
> T

I wish below would "just work"


// ----
module test;

import std;

@safe
void main()
{
     //int[5] arr = [1, 2, 3, 4, 5]; // nope. won't work with 
.parallel
     int[] arr = [1, 2, 3, 4, 5];// has to by dynamic to work with 
.parallel ??

     int x = 0;

     foreach(n; arr.parallel) // Nope - .parallel is a @system 
function and cannot be called in @safe
     {
         x += n;
     }

     writeln(x);
}
// -----


More information about the Digitalmars-d mailing list