Answer the question
In order to leave comments, you need to log in
How to execute one function for all vector elements at the same time?
Yes vector<T> vec
, function .
I want to execute the function f for each element in vec, and store all the results in ;
This can be done with a loopbool f(T)
vector<bool> res
for(auto &i: vec)
{
res.push_back(f(i));
}
Answer the question
In order to leave comments, you need to log in
https://en.cppreference.com/w/cpp/experimental/par...
https://github.com/intel/parallelstl/blob/master/R...
OpenMP
Naturally, there is nothing suitable out of the box.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question