Changes

Jump to: navigation, search

Team Hortons

91 bytes removed, 17:12, 29 October 2017
no edit summary
These executions are passed as the first parameter for the algorithm:
<code><pre>
std::copy(
std::execution::par,
b.start()
);
</pre></code>
Most compilers nowadays do not yet support this feature. Probably the only compiler that can already make use of these policies is the Intel C++ Compiler, which was used to perform the tests below.
Copying values from array ''a'' to array ''b''.
<code><pre>
std::copy(
std::execution::par,
b
);
</pre></code>
''Results''
''Snippet:''
<code><pre>
// Counting all multiples of 3
auto condition = [](mytype& i) { return i % 3 == 0; };
condition
);
</pre></code>
''Results:''
''Snippet:''
<code><pre>
size_t sum;
auto action = [&](mytype& i) { return sum += i; };
action
);
</pre></code>
Notice how this **for_each** behaves like a **reduce**: I am modifying the variable "sum" outside of this function. This is very likely to cause a **race condition**.
''Snippet:''
<code><pre>
size_t sum = std::reduce(
std::execution::par,
a.end()
);
</pre></code>
''Results:''
This algorithm is a bit different: we cannot use ''std::list'' with it. Since the algorithm requires random access, it is only possible to use arrays or vectors.
<code><pre>
auto sorter = [](mytype a, mytype b) { return a < b; };
sorter
);
</pre></code>
''Results:''
''Snippet:''
<code><pre>
auto action = [](mytype i) { return i += 5; };
action
);
</pre></code>
''Results:''

Navigation menu