I use PPL and parallel_for for the syntax for the for loop. In the capture clause, I have 3 variables, one of which is a member of the class. There is a compilation error due to the presence of a class member among the variables in the capture clause. However, if I have this class member in a lambda body, it does not compile either, and the indicated error is that the variable in the enclosing area should be in the capture clause. How to act? Should I copy the variable element to a local variable in advance and pass it to the capture clause?
Here is the code with the formula Command member of the class.
parallel_for (m_rowStart,m_rowEnd+1,[&functionEvaluation,varModel_,formulaCommand](int i) { MLEquationVariableModel model_(varModel_); model_.addVariable("i", i); model_.addVariable("j", 1); MLEquationCommand* command_ = formulaCommand->duplicate(&model_); double d = command_->execute().toDouble(); if(d==NO_VALUE) { functionEvaluation.local() = NO_VALUE; } else { functionEvaluation.local() += d; } delete command_; });
Thanks!
c ++ lambda parallel-processing ppl
octoback
source share